Forum Discussion
Sharepoint JSON - display a button if two columns exist
- Feb 03, 2021
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 documentation: Use 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
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 documentation: Use 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
- Anonuser1981Feb 03, 2021Copper Contributor
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.