Forum Discussion

WorkflowIQ's avatar
WorkflowIQ
Copper Contributor
Nov 11, 2021
Solved

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

  • WorkflowIQ's avatar
    WorkflowIQ
    Copper 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')"

     

  • WorkflowIQ's avatar
    WorkflowIQ
    Copper Contributor
    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?


Resources