0

I need to format a column named 'Action' with hyperlink as follows:

  • If column name 'Status' is having value as "Accepted" or "Rejected" then 'Action' column should have hyperlink as 'View' and on click of it it should open view form.
  • Else if column name 'Status' is having any other value, then 'Action' column should have hyperlink as 'Edit' and on click of it it should open edit form.

Any help will be appreciated.

3
  • 1
    Just wanted to confirm if you are using a "list" or "document library"? Generally libraries only have a "Properties" form. Commented May 24, 2024 at 18:26
  • Thank you @GaneshSanap-MVP for your reply. I'm using Document Library. This Status is custom column which shows current Status of that item. Basically, I want to provide Edit functionality for In-Progress items & if item's status is Accepted/Rejected, then users can only View them with this link. I'm using List Based PowerApps Form to edit/view item details. PowerApps form is working fine. Now using JSON formatting I want to customize this Action column & redirect based on Status. Thanks, Sanjay Commented May 26, 2024 at 6:19
  • Check my answer below and let me know if it helps. Commented May 27, 2024 at 9:53

2 Answers 2

1

The button seems to do this, please refer:

https://michelcarlo.com/2022/05/19/sharepoint-custom-view-and-edit-buttons-using-list-formatting/

1

You can try using SharePoint JSON column formatting like below for your Action column to open the forms based on "Status":

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "=if([$Status]=='Accepted' || [$Status]=='Rejected', 'View', 'Edit') + ' Form'",
  "attributes": {
    "href": "=@currentWeb + '/Shared Documents/Forms/' + if([$Status]=='Accepted' || [$Status]=='Rejected', 'dispform', 'editform') + '.aspx?ID=' + [$ID]",
    "target": "_blank"
  }
}

Where:

  1. [$Status] is an internal name of your column in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
  2. Shared Documents is the name of document library you can find from library URL: Check SharePoint Online List/Library URL Name.

Output:

enter image description here


Additional:

You can try using SharePoint JSON column formatting like below for your Action column to open the "Properties" form for all conditions:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Open Form",
  "customRowAction": {
    "action": "editProps"
  }
}

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.