SOLVED

JSON column formatting on Approval status broken?

%3CLINGO-SUB%20id%3D%22lingo-sub-2952998%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20broken%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2952998%22%20slang%3D%22en-US%22%3EI%20have%20performed%20some%20testing%20(by%20elimination)%20and%20the%20issue%20seems%20to%20be%20with%20the%20if%20statement%20looking%20at%20the%20status%20of%20the%20approval.%20If%20I%20change%3A%3CBR%20%2F%3E%22%22visibility%22%3A%20%7B%3CBR%20%2F%3E%22operator%22%3A%20%22%3F%22%2C%3CBR%20%2F%3E%22operands%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22operator%22%3A%20%22%3D%3D%22%2C%3CBR%20%2F%3E%22operands%22%3A%20%5B%3CBR%20%2F%3E%22%5B%24_ModerationStatus%5D%22%2C%3CBR%20%2F%3E%22Pending%22%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22visible%22%2C%3CBR%20%2F%3E%22hidden%22%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%22%3CBR%20%2F%3E%3CBR%20%2F%3Eto%3CBR%20%2F%3E%3CBR%20%2F%3E%22visibility%22%3A%20%22visible%22%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20buttons%20show%20and%20work%20correctly%20except%20they%20always%20show.%20I%20need%20them%20to%20only%20show%20when%20the%20status%20of%20the%20document%20is%20%22Pending%22%20as%20the%20button%20launches%20a%20document%20approval%20flow.%3CBR%20%2F%3E%3CBR%20%2F%3EDoes%20anyone%20know%20if%20there%20were%20any%20changes%20to%20the%20way%20the%20approval%20Status%20is%20handled%20in%20SP%20JSON%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2952937%22%20slang%3D%22en-US%22%3EJSON%20column%20formatting%20broken%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2952937%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20just%20noticed%20today%20that%20a%20formatted%20column%20button%20I%20use%20in%20SharePoint%20libraries%20for%20many%20different%20customers%20no%20longer%20shows.%20I%20have%20checked%20multiple%20tenants%20where%20the%20JSON%20for%20the%20button%20has%20not%20changed%20for%20a%20long%20time%2C%20suddenly%20no%20longer%20displays.%20It%20was%20displaying%20correctly%20the%20last%20time%20i%20checked%20a%20few%20days%20ago.%20Can%20someone%20else%20please%20check%3F%20It%20may%20be%20system%20wide%20and%20affect%20a%20lot%20of%20people.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESample%20JSON%20below%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%0A%22elmType%22%3A%20%22button%22%2C%0A%22txtContent%22%3A%20%22%3Dif(%5B%24ReviewStatus%5D%3D%3D'Approval'%2C'Sent%20for%20Approval'%2Cif(%5B%24ReviewStatus%5D%3D%3D'Review'%2C'Review%20in%20progress'%2C'Send%20for%20Approval'))%22%2C%0A%22customRowAction%22%3A%20%7B%0A%22action%22%3A%20%22executeFlow%22%2C%0A%22actionParams%22%3A%20%22%3D'%7B%5C%22id%5C%22%3A%20%5C%22'%20%2B%20if(%5B%24ReviewStatus%5D%3D%3D''%2C'Flowidhere'%2Cif(%5B%24ReviewStatus%5D%3D%3D'No'%2C'Flowidhere'%2C'%20'))%20%2B%20'%5C%22%7D'%22%0A%7D%2C%0A%22style%22%3A%20%7B%0A%22background-color%22%3A%20%22%3Dif(%5B%24ReviewStatus%5D%3D%3D'Approval'%2C'Orange'%2Cif(%5B%24ReviewStatus%5D%3D%3D'Review'%2C'Red'%2C'Green'))%22%2C%0A%22color%22%3A%20%22white%22%2C%0A%22border-radius%22%3A%20%2220px%22%2C%0A%22border-style%22%3A%20%22solid%22%2C%0A%22border-color%22%3A%20%22white%22%2C%0A%22border-width%22%3A%20%224px%22%2C%0A%22visibility%22%3A%20%7B%0A%22operator%22%3A%20%22%3F%22%2C%0A%22operands%22%3A%20%5B%0A%7B%0A%22operator%22%3A%20%22%3D%3D%22%2C%0A%22operands%22%3A%20%5B%0A%22%5B%24_ModerationStatus%5D%22%2C%0A%22Pending%22%0A%5D%0A%7D%2C%0A%22visible%22%2C%0A%22hidden%22%0A%5D%0A%7D%0A%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2952937%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2969464%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20broken%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2969464%22%20slang%3D%22en-US%22%3EAlso%20seeing%20this%20issue%20under%20the%20exact%20same%20circumstances%20(you%20are%20not%20alone!)%3CBR%20%2F%3E%3CBR%20%2F%3EUnfortunately%20I%20have%20not%20found%20a%20fix%20for%20this%20myself.%20Hopefully%20someone%20else%20can%20shed%20some%20light%20on%20this%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2972664%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20broken%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2972664%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1220031%22%20target%3D%22_blank%22%3E%40Danie365%3C%2FA%3E%26nbsp%3BThere%20is%20another%20post%20where%20someone%20has%20given%20an%20answer%20saying%20there%20was%20a%20change%20to%20how%20JSON%20handles%20the%20Approval%20Status%20column.%20I%20am%20not%20super%20skilled%20in%20JSON%20so%20I%20am%20trying%20to%20work%20out%20myself%2C%20and%20ask%20a%20few%20others%20what%20the%20replacement%20code%20would%20be.%20I%20will%20post%20here%20if%20I%20work%20it%20out%20or%20someone%20helps%20us%20out%20with%20this%20one.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPost%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsharepoint%2Fjson-format-broken%2Fm-p%2F2968990%2Fhighlight%2Ffalse%23M55139%22%20target%3D%22_self%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fsharepoint%2Fjson-format-broken%2Fm-p%2F2968990%2Fhighlight%2Ffalse%23M55139%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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 (Occasional 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')"