Forum Discussion

JasonC4's avatar
JasonC4
Copper Contributor
Apr 01, 2022
Solved

List - Conditional formatting for blank text field

I'm using Lists via Teams (Office 365). I've got a list with a "single line text" column. I'd like to add some conditional formatting if the column contents are not blank.   The only options I see ...
  • Micca0815's avatar
    Apr 01, 2022

    JasonC4 

    You might want to open the 'Advanced mode' linked at the very bottom above the save button.
    In here the operand accepts double quotes for 'blank fields' (line 18).

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "0 2px",
        "overflow": "hidden",
        "text-overflow": "ellipsis"
      },
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$SingleLineOfText]",
                ""
              ]
            },
            "sp-css-backgroundColor-BgGold",
            ""
          ]
        }
      },
      "txtContent": "[$SingleLineOfText]"
    }

     

Resources