Forum Discussion

Anonuser1981's avatar
Anonuser1981
Copper Contributor
Feb 02, 2021

Sharepoint JSON - display a button if two columns exist

Hi, I have been trying to figure this out - but no joy and I was hoping that someone here could help me.  I want to display a button based on the validation of two columns.  The first one is when ...
  • ganeshsanap's avatar
    Feb 03, 2021

    Anonuser1981 

     

    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 documentationUse 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

Resources