Forum Discussion

SG523's avatar
SG523
Brass Contributor
Feb 22, 2022
Solved

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...
  • RobElliott's avatar
    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)

Resources