Forum Discussion
SG523
Feb 22, 2022Brass Contributor
SharePoint Json If statement for visibility
Hello, I have a column in a SP library with the following Json. I'm wondering if there is a way to make the button "hidden" and not clickable based on another column? I need this button to only s...
- Feb 23, 2022
SG523 there's a simpler JSON code that you can use and where you set the visibility property:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "button", "txtContent": "Publish to Teams", "customRowAction": { "action": "executeFlow", "actionParams": "='{\"id\":\"021ec4e0-8f85-46b3-a557-a4456960a4eb\", \"headerText\":\"Publish ' + [$Title] + '\",\"runFlowButtonText\":\"Publish now\"}'" }, "style": { "background-color": "#008082", "color": "white", "border-radius": "10px", "visibility": "=if([$PublishedToTeams] == 'Yes','hidden','visible')" } }
The result is:
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
RobElliott
Feb 23, 2022Silver Contributor
SG523 there's a simpler JSON code that you can use and where you set the visibility property:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Publish to Teams",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\":\"021ec4e0-8f85-46b3-a557-a4456960a4eb\", \"headerText\":\"Publish ' + [$Title] + '\",\"runFlowButtonText\":\"Publish now\"}'"
},
"style": {
"background-color": "#008082",
"color": "white",
"border-radius": "10px",
"visibility": "=if([$PublishedToTeams] == 'Yes','hidden','visible')"
}
}
The result is:
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
SG523
Feb 23, 2022Brass Contributor
That works perfectly! I didn't know there was a visibility property!
Thank you!
Thank you!