Enabling a JSON schema to work to a column

Copper Contributor

I created a new SharePoint List and 2 columns included in the list are: Status and Approval.

The Status field has "Requested, Reviewed, Rejected, Approved, Executed".

The Approval field is a calculated column and I copy this json schema from a colleague

 

{"$schema":"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json","elmType":"div","style":{"flex-directon":"row","justify-content":"left","align-items":"center","flex-wrap":"nowrap"},"children":[{"elmType":"div","style":{"display":"=if([$Status] == 'Requested' || [$Status] == '', 'inherit','none')","flex-directon":"row","justify-content":"left","align-items":"center","flex-wrap":"wrap"},"children":[{"elmType":"button","customRowAction":{"action":"setValue","actionInput":{"Status":"Approved","ApprovalActionBy":"@me","ApprovalDate":"=toLocaleDateString(@now)"}},"attributes":{"class":"ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"},"style":{"border":"none","background-color":"transparent","cursor":"pointer","display":"flex","flex-directon":"row","justify-content":"left","align-items":"center","flex-wrap":"wrap"},"children":[{"elmType":"span","attributes":{"iconName":"SkypeCircleCheck"},"style":{"padding":"4px"}},{"elmType":"span","txtContent":"Approve","style":{"word-break":"keep-all"}}]},{"elmType":"button","customRowAction":{"action":"setValue","actionInput":{"Status":"Rejected","ApprovalActionBy":"@me"}},"attributes":{"class":"ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"},"style":{"border":"none","background-color":"transparent","cursor":"pointer","display":"flex","flex-directon":"row","justify-content":"left","align-items":"center","flex-wrap":"wrap"},"children":[{"elmType":"span","attributes":{"iconName":"Blocked"},"style":{"padding":"4px"}},{"elmType":"span","txtContent":"Reject","style":{"word-break":"keep-all"}}]}]},{"elmType":"div","children":[{"elmType":"span","txtContent":"='This item is ' + toLowerCase([$Status])","style":{"display":"=if([$Status] == 'Requested' ||[$Status] == '' , 'none','inherit')","padding-left":"5px","word-break":"keep-all"}}]}]}

 

I need guidance on how to use the schema above as it allows a manager to select either Approved or Rejected and the Status is derived accordingly. Currently it doesn't work for me yet.

 

Thanks for your help...

biTiqa

2 Replies

@biTiqa check column names are they same as mentioned in json, as i feel only issue is in Json it is ApprovalDate and as you mentioned you created column as Approval.

Pls check

 

Br,

Suvi

@biTiqa Can you explain more about your requirements? Add screenshot if possible showing the dummy data and expected results in list view.

 

Also, SharePoint JSON formatting works with internal name of columns used in JSON. Follow below article for finding correct internal names of your columns and adjust the JSON accordingly: How to find the Internal name of columns in SharePoint Online? 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.