SOLVED

List - Conditional formatting for blank text field

%3CLINGO-SUB%20id%3D%22lingo-sub-3273859%22%20slang%3D%22en-US%22%3EList%20-%20Conditional%20formatting%20for%20blank%20text%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3273859%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20using%20Lists%20via%20Teams%20(Office%20365).%20I've%20got%20a%20list%20with%20a%20%22single%20line%20text%22%20column.%20I'd%20like%20to%20add%20some%20conditional%20formatting%20if%20the%20column%20contents%20are%20not%20blank.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20only%20options%20I%20see%20in%20the%20conditional%20formatting%20dialog%20are%20%22is%20equal%20to%22%20and%20%22is%20not%20equal%20to%22%2C%20so%20I%20picked%20%22is%20not%20equal%20to%22%2C%20but%20it%20won't%20accept%20an%20empty%20value%20in%20the%20%22choose%20a%20type%20or%20value%22%20box%20(which%20is%20a%20plain%20text%20field%2C%20it's%20not%20a%20dropdown).%20I%20tried%20empty%20single%20quotes%20and%20empty%20double%20quotes%20but%20that%20didn't%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JasonC4_0-1648828293369.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F360609iB73ADE613C2275EA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JasonC4_0-1648828293369.png%22%20alt%3D%22JasonC4_0-1648828293369.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20I%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3273859%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Lists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUsage%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3273965%22%20slang%3D%22en-US%22%3ERe%3A%20List%20-%20Conditional%20formatting%20for%20blank%20text%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3273965%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1350478%22%20target%3D%22_blank%22%3E%40JasonC4%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20might%20want%20to%20open%20the%20'Advanced%20mode'%20linked%20at%20the%20very%20bottom%20above%20the%20save%20button.%3CBR%20%2F%3EIn%20here%20the%20operand%20accepts%20double%20quotes%20for%20'blank%20fields'%20(line%2018).%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22box-sizing%22%3A%20%22border-box%22%2C%0A%20%20%20%20%22padding%22%3A%20%220%202px%22%2C%0A%20%20%20%20%22overflow%22%3A%20%22hidden%22%2C%0A%20%20%20%20%22text-overflow%22%3A%20%22ellipsis%22%0A%20%20%7D%2C%0A%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%22class%22%3A%20%7B%0A%20%20%20%20%20%20%22operator%22%3A%20%22%3A%22%2C%0A%20%20%20%20%20%20%22operands%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22operator%22%3A%20%22%3D%3D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22operands%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%5B%24SingleLineOfText%5D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%0A%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22sp-css-backgroundColor-BgGold%22%2C%0A%20%20%20%20%20%20%20%20%22%22%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22txtContent%22%3A%20%22%5B%24SingleLineOfText%5D%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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 in the conditional formatting dialog are "is equal to" and "is not equal to", so I picked "is not equal to", but it won't accept an empty value in the "choose a type or value" box (which is a plain text field, it's not a dropdown). I tried empty single quotes and empty double quotes but that didn't work.

 

JasonC4_0-1648828293369.png

 

How do I do this?

 

Thanks!!

1 Reply
best response confirmed by JasonC4 (Occasional Contributor)
Solution

@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]"
}