SOLVED

Sharepoint JSON - display a button if two columns exist

Copper Contributor

Hi,

I have been trying to figure this out - but no joy and I was hoping that someone here could help me. 

I want to display a button based on the validation of two columns. 

The first one is when column "Status_value" = Pending AND column "Owner" = not empty.

I can't seem to figure out how to get validation on second column in there. 

Thank you in advance for your help.

 

Here is the JSON code I have so far:

 

{
"elmType": "button",
"txtContent": "Get Approved",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"6ff70d5d-977d-42c4-8989-41c6c9fc16b2\"}"
},
"style": {
"background-color": "#004B8B",
"padding": "10px 10px",
"border": "2px solid white",
"text-align": "center",
"font-size": "12px",
"color": "white",
"display": "inline-block",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Status_value]",
"Pending"
]
},
"",
"hidden"
]
}
}
}

 

2 Replies
best response confirmed by Anonuser1981 (Copper Contributor)
Solution

@Anonuser1981 

 

Which version of SharePoint you are using? You can use [$Owner.title] != '' to check if Owner field is empty or not.

 

If you are using SharePoint online, use below JSON code for your requirements. If you are using SharePoint 2019 then convert this in AST format using the above condition for Owner field:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Get Approved",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"6ff70d5d-977d-42c4-8989-41c6c9fc16b2\"}"
  },
  "style": {
    "background-color": "#004B8B",
    "padding": "10px 10px",
    "border": "2px solid white",
    "text-align": "center",
    "font-size": "12px",
    "color": "white",
    "display": "=if([$Status_value] == 'Pending' && [$Owner.title] != '', 'block' , 'none')"
  }
}

 

Note: You need to use internal name of Status_value and Owner column in JSON.

 

Microsoft documentationUse column formatting to customize SharePoint 


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 Thank you so much!!

Really appreciate your help with this. What happened was I named the column wrong and that threw me off :) It was named something differently at the beginning at that was the issue. 

How you explained it was so clear. 

1 best response

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

@Anonuser1981 

 

Which version of SharePoint you are using? You can use [$Owner.title] != '' to check if Owner field is empty or not.

 

If you are using SharePoint online, use below JSON code for your requirements. If you are using SharePoint 2019 then convert this in AST format using the above condition for Owner field:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Get Approved",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"6ff70d5d-977d-42c4-8989-41c6c9fc16b2\"}"
  },
  "style": {
    "background-color": "#004B8B",
    "padding": "10px 10px",
    "border": "2px solid white",
    "text-align": "center",
    "font-size": "12px",
    "color": "white",
    "display": "=if([$Status_value] == 'Pending' && [$Owner.title] != '', 'block' , 'none')"
  }
}

 

Note: You need to use internal name of Status_value and Owner column in JSON.

 

Microsoft documentationUse column formatting to customize SharePoint 


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