Search code examples
jsonsharepointformatconditional-statements

Sharepoint List conditional format if major version is published


I am trying to conditional format my sharepoint list so that I highlight files that has been published, ie. version does not contain "0."

I could not find out to use wildcard, so the below code with "0." was replaced with "0.*" did not work.

Can I change the operator from "!=" to something else that means contains or not contains?

{
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
      "additionalRowClass": {
        "operator": ":",
        "operands": [
          {
            "operator": "!=",
            "operands": [
              "[$_UIVersionString]",
              "0."
            ]
          },
          "sp-css-backgroundColor-BgMintGreen sp-field-fontSizeSmall sp-css-color-MintGreenFont",
          ""
        ]
      }
    }

Solution

  • Try using this JSON:

    {
        "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
        "additionalRowClass": "=if(indexOf([$_UIVersionString], '0.') >= 0, '', 'sp-css-backgroundColor-BgMintGreen sp-field-fontSizeSmall sp-css-color-MintGreenFont')"
    }
    

    Documentation: SharePoint JSON formatting-syntax-reference