SOLVED

JSON Column Formatting in Sharepoint based on an address field

Brass Contributor

In my Sharepoint List, I want to hide a button if the user hasn't entered an address. The field is a Location field called "Address" and I cannot get the syntax correct. The JSON code extract is below (and for the avoidance of any doubt, the first part of the IF statement works fine.)

I have tried $Address.Name, $Address.Street, $Address.value ... I just can't seem to get it

 

"visibility": "=if([$RTWVALIDATERef] == '' || [$Address] == '','hidden','visible')"

 

Any help would be greatly appreciated.

2 Replies
best response confirmed by Geoffers (Brass Contributor)
Solution

@GeoffersThere is no direct way but you can always use a workaround. Like shown below

Vikram_Samal_2-1593019753328.png

 

Step 1: Create a Calculated Column And add the formula which checks the Address is empty or not. Like shown below: (I am making sure address should have a postal code)

Vikram_Samal_1-1593019602359.png

 

Step2: Then use that column to check if the Address is present then show or hide the button on the basis of Calculated column.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#0078d7",
    "background-color": "White",
    "visibility": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$CheckAddress]",
            "Present"
          ]
        },
        "visible",
        "hidden"
      ]
    }
  },
  "children": [
    {
      "elmType": "span"
    },
    {
      "elmType": "button",
      "txtContent": "Send Mail",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"e290feff-0013-41f2-97dd-91a37fb84ea0\"}"
      }
    }
  ]
}

 

Vik
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@Vikram_Samal 

Thank you for this solution. It works perfectly. I have added more address fields to the formula  to make for a more robust check but the principle is exactly as you have outlined.  My formula is 

 

=IF(AND(ISBLANK([Address: Postal Code]),ISBLANK([Address: Street]),ISBLANK([Address: Name])),"Empty","Present")

1 best response

Accepted Solutions
best response confirmed by Geoffers (Brass Contributor)
Solution

@GeoffersThere is no direct way but you can always use a workaround. Like shown below

Vikram_Samal_2-1593019753328.png

 

Step 1: Create a Calculated Column And add the formula which checks the Address is empty or not. Like shown below: (I am making sure address should have a postal code)

Vikram_Samal_1-1593019602359.png

 

Step2: Then use that column to check if the Address is present then show or hide the button on the basis of Calculated column.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#0078d7",
    "background-color": "White",
    "visibility": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$CheckAddress]",
            "Present"
          ]
        },
        "visible",
        "hidden"
      ]
    }
  },
  "children": [
    {
      "elmType": "span"
    },
    {
      "elmType": "button",
      "txtContent": "Send Mail",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"e290feff-0013-41f2-97dd-91a37fb84ea0\"}"
      }
    }
  ]
}

 

Vik
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post