Forum Discussion
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 show and be clickable in rows where the column [$ApprovalLink] is not None. I imagine something like an IF that applies the Json if Approval Link is not None but if it is None if just makes it blank or act blank? Is this possible?
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)
- RobElliottSilver 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)- SG523Brass ContributorThat works perfectly! I didn't know there was a visibility property!
Thank you!