Forum Discussion
JSON column formatting on Approval status broken?
Hi all,
I have just noticed today that a formatted column button I use in SharePoint libraries for many different customers no longer shows. I have checked multiple tenants where the JSON for the button has not changed for a long time, suddenly no longer displays. It was displaying correctly the last time i checked a few days ago. Can someone else please check? It may be system wide and affect a lot of people.
Sample JSON below
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "=if([$ReviewStatus]=='Approval','Sent for Approval',if([$ReviewStatus]=='Review','Review in progress','Send for Approval'))",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\": \"' + if([$ReviewStatus]=='','Flowidhere',if([$ReviewStatus]=='No','Flowidhere',' ')) + '\"}'"
},
"style": {
"background-color": "=if([$ReviewStatus]=='Approval','Orange',if([$ReviewStatus]=='Review','Red','Green'))",
"color": "white",
"border-radius": "20px",
"border-style": "solid",
"border-color": "white",
"border-width": "4px",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$_ModerationStatus]",
"Pending"
]
},
"visible",
"hidden"
]
}
}
}
Thanks to @ganeshsanap and @Danie365 for the help with the below. I have tested and it works for me.
"visibility": "=if([$_ModerationStatus.displayValue] == 'Pending', 'visible', 'hidden')"
4 Replies
- WorkflowIQCopper Contributor
Thanks to @ganeshsanap and @Danie365 for the help with the below. I have tested and it works for me.
"visibility": "=if([$_ModerationStatus.displayValue] == 'Pending', 'visible', 'hidden')" - WorkflowIQCopper ContributorI have performed some testing (by elimination) and the issue seems to be with the if statement looking at the status of the approval. If I change:
""visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$_ModerationStatus]",
"Pending"
]
},
"visible",
"hidden"
]
}"
to
"visibility": "visible"
The buttons show and work correctly except they always show. I need them to only show when the status of the document is "Pending" as the button launches a document approval flow.
Does anyone know if there were any changes to the way the approval Status is handled in SP JSON?- Danie365Brass ContributorAlso seeing this issue under the exact same circumstances (you are not alone!)
Unfortunately I have not found a fix for this myself. Hopefully someone else can shed some light on this- WorkflowIQCopper Contributor
Danie365 There is another post where someone has given an answer saying there was a change to how JSON handles the Approval Status column. I am not super skilled in JSON so I am trying to work out myself, and ask a few others what the replacement code would be. I will post here if I work it out or someone helps us out with this one.
Post: