Forum Discussion

sboley's avatar
sboley
Copper Contributor
Jul 26, 2024
Solved

Using Conditional Formatting to make a field blank if another field is blank

I have a document library where I would like one column (Reject) to be blank if another column (Reject Reason) is blank. Can I use conditional formatting to do this?

 

Here is my current JSON on the Reject column:

 

 

  • sboley you can do this with the following JSON, changing the details to your own of course. It is the visibility property you need to use to display or hide the button that runs the flow.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "button",
      "txtContent": "Change Owner",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "='{\"id\":\"5eddbaca-e7df-46f4-b968-f009ed9f69ec\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Go\"}'"
      },
      "style": {
        "background-color": "#fff5dd",
        "border-radius": "10px",
        "visibility": "=if([$Reason] =='', 'hidden', 'visible')"
      }
    }

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

2 Replies

  • Rob_Elliott's avatar
    Rob_Elliott
    Silver Contributor

    sboley you can do this with the following JSON, changing the details to your own of course. It is the visibility property you need to use to display or hide the button that runs the flow.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "button",
      "txtContent": "Change Owner",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "='{\"id\":\"5eddbaca-e7df-46f4-b968-f009ed9f69ec\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Go\"}'"
      },
      "style": {
        "background-color": "#fff5dd",
        "border-radius": "10px",
        "visibility": "=if([$Reason] =='', 'hidden', 'visible')"
      }
    }

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)