SOLVED

JSON format broken?

Copper Contributor

Hi, 

 

Some days ago i have a incident with two differents lists, this problem probably due a Microsoft change in the SP Online. The first problem: in the attached screenshot a week ago i don't have these values in the columns, i have "Pending", "Approved", "Rejected", etc. 

 

My second problem. i have a text column with a specific JSON code to start a workflow in PowerAutomate but the JSON code appears with in the final view i have a blank column.... See the second screenshot.

 

My JSON code attached.

 

Any with a similar problem? You can help me? Thanks in advance.

 

16 Replies
Hi,

I am having exactly the same issue. I have checked multiple tenants where a similar JSON is used in a number of libraries and the same issue is show for all. Can we please get some feedback from Microsoft??

My post:

https://techcommunity.microsoft.com/t5/sharepoint/json-column-formatting-broken/m-p/2952937
best response confirmed by Jordaromera (Copper Contributor)
Solution

@WorkflowIQ @Jordaromera,

This is happening because of recent change in JSON schema to officially support Approval Status column in JSON formatting.

 

Due to this update, the @currentField and [$_ModerationStatus] will resolve to internal code (enum value) and @currentField.displayValue and [$_ModerationStatus.displayValue] will resolve to the localized string (I guess according to language).

 

The Microsoft official docs will be updated with more info in the coming weeks. You can check the details for now at: SharePoint Online Column Formatting for Approval Status: uses language specific text? 

 

Similar threadApproval Status Column Suddenly Numeric - Due to Column Formatting? 

Related ReadHow 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.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

@ganeshsanap  Thanks thanks and thanks, this is the start point to solve the problem. Again: Thanks!

@ganeshsanap @Jordaromera Thanks, I am not as skilled in JSON as i would like to be, so can you help with my code? The code i was using was as below. What would it change to, to meet the requirements of the new Moderationstatus changes?

 

 

 

"visibility": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$_ModerationStatus]",
            "Pending"
          ]
        },
        "visible",
        "hidden"
      ]
    }

 

 

 

Hey @WorkflowIQ thanks for pointing me to this thread and thanks @ganeshsanap for the reply above, worked perfectly and no way I would have figured it out.

 

It would be helpful if Microsoft planned to have the documentation updated for when the change is pushed out....

 

Anyway, @WorkflowIQ  if you just replace [$_moderationStatus] with [$_moderationStatus.displayValue] in your code you should be good to go. That worked for me.

 

Thanks again for the heads up!

@Danie365 Thanks.

I agree. It looks like Microsoft added a feature that someone requested, and broke something that already worked. Changing [$_moderationStatus] with [$_moderationStatus.displayValue] didn't work for me for some reason. It may be something simple i have missed, as i have been staring at this code for days.... The column still is not showing for files where the Approval Status is "Pending".

 

Can you please take a quick look to see if you can see something i have done wrong? 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + if([$ReviewInProgress]=='','xxxxxxxx',if([$ReviewInProgress]=='No','xxxxxxxxx',' ')) + '\"}'"
  },
  "txtContent": "=if([$ReviewInProgress]=='Approval','Sent for Approval','Send for Approval')",
  "style": {
    "background-color": "=if([$ReviewInProgress]=='Approval','Orange','Green')",
    "color": "white",
    "border-radius": "20px",
    "border-style": "solid",
    "border-color": "white",
    "border-width": "4px",
    "visibility": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$_moderationStatus.displayValue]",
            "Pending"
          ]
        },
        "visible",
        "hidden"
      ]
    }
    }
  }

 

@Danie365 . I found this post also which details how the issue happened.

 

https://github.com/SharePoint/sp-dev-docs/issues/7513 

Hey @WorkflowIQ, try this...

 

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "button",
    "customRowAction": {
      "action": "executeFlow",
      "actionParams": "='{\"id\": \"' + if([$ReviewInProgress]=='','xxxxxxxx',if([$ReviewInProgress]=='No','xxxxxxxxx',' ')) + '\"}'"
    },
    "txtContent": "=if([$ReviewInProgress]=='Approval','Sent for Approval','Send for Approval')",
    "style": {
      "background-color": "=if([$ReviewInProgress]=='Approval','Orange','Green')",
      "color": "white",
      "border-radius": "20px",
      "border-style": "solid",
      "border-color": "white",
      "border-width": "4px",
      "visibility": "=if(([$_moderationStatus.displayValue] == ‘Pending’),’visible’,’hidden’)"
      }
    }

@Danie365 Thanks for the help, i really appreciate it. I still can't get it to work though. I pasted your code exactly, just adding my correct flow id, and replacing the single quotes (as they paste a different character if copying from here). Do you have any other suggections on what could be wrong? Thanks again, screenshot below.

 

Screenshot 2021-11-17 111113.png

@WorkflowIQ are the "txtContent" and "background-color" missing a set or parenthesisssssssss (no idea how to spell the plural of that!)...

 

I'm just brainstorming now as my lack of code knowledge is  going to become apparent...

 

but maybe try this...

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "button",
    "customRowAction": {
      "action": "executeFlow",
      "actionParams": "='{\"id\": \"' + if([$ReviewInProgress]=='','xxxxxxxx',if([$ReviewInProgress]=='No','xxxxxxxxx',' ')) + '\"}'"
    },
    "txtContent": "=if(([$ReviewInProgress]=='Approval'),'Sent for Approval','Send for Approval')",
    "style": {
      "background-color": "=if(([$ReviewInProgress]=='Approval'),'Orange','Green')",
      "color": "white",
      "border-radius": "20px",
      "border-style": "solid",
      "border-color": "white",
      "border-width": "4px",
      "visibility": "=if(([$_moderationStatus.displayValue] == ‘Pending’),’visible’,’hidden’)"
      }
    }

 

@Danie365 LOL, I have no idea either about the plural, i usually give in and Google it :)

 

The rest of the code is OK, i tested by just replacing 

"visibility": "=if(([$_moderationStatus.displayValue] == ‘Pending’),’visible’,’hidden’)"

with

"visibility": "visible"

 

and everything else works. (the button i am trying to conditionally hide always shows though of course)

 

I also tried dropping one of the parenthesisss so that is is:

 

"visibility": "=if([$_moderationStatus.displayValue]=='Pending','visible','hidden')"
 
Still no luck....... I'll keep looking and post back here when I have something that works.
 
Thanks again!!
 
 

@WorkflowIQ Try using:

 

"visibility": "=if([$_ModerationStatus.displayValue] == 'Pending', 'visible', 'hidden')"

 

 OR instead of "visibility", use this:

 

"display": "=if([$_ModerationStatus.displayValue] == 'Pending', 'block', 'none')"

 

Use [$_ModerationStatus.displayValue] with capital M.

 

Also, are you using SharePoint online or SharePoint 2019? 


Please consider giving a Like if my post helped you in any way.

@ganeshsanap Thanks, that worked! I used "visibility" but Display seemed to work also. I am very grateful for your help. This has taken so much of my time trying to work out. 

I was on SP online by the way

@Jordaromera You're welcome. Glad it helped you!


Please consider giving a Like if my post helped you in any way.

@WorkflowIQ Great, glad it worked you!

you can use either one to show/hide the element. But, I prefer "display: none" property as it completely removes the element from DOM. Check this for more information: What is the difference between visibility:hidden and display:none? 


Please consider giving a Like if my post helped you in any way.

1 best response

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

@WorkflowIQ @Jordaromera,

This is happening because of recent change in JSON schema to officially support Approval Status column in JSON formatting.

 

Due to this update, the @currentField and [$_ModerationStatus] will resolve to internal code (enum value) and @currentField.displayValue and [$_ModerationStatus.displayValue] will resolve to the localized string (I guess according to language).

 

The Microsoft official docs will be updated with more info in the coming weeks. You can check the details for now at: SharePoint Online Column Formatting for Approval Status: uses language specific text? 

 

Similar threadApproval Status Column Suddenly Numeric - Due to Column Formatting? 

Related ReadHow 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.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

View solution in original post