SOLVED

JSON column formatting on Approval status broken?

Copper Contributor

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"
]
}
}
}

 

 

 

 

4 Replies
I 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?


Also 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

@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:

https://techcommunity.microsoft.com/t5/sharepoint/json-format-broken/m-p/2968990/highlight/false#M55... 

best response confirmed by WorkflowIQ (Copper Contributor)
Solution

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')"

 

1 best response

Accepted Solutions
best response confirmed by WorkflowIQ (Copper Contributor)
Solution

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')"

 

View solution in original post