Conditional formatting for blank FORM fields

Copper Contributor
{
  "$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]"
}

 

Conditional formatting works great on list views using the code snippet above; however, It does not work for any of the form views.  I've tried multiple methods to try to highlight a blank field (number or text) on a form field but nothing has worked so far.  Do you know why this is?

 

List View with formatting looks great.

Shaune1215_0-1713071597502.png

 

Form View formatting is not present.  Instead SP displays an em dash?

Shaune1215_1-1713071597355.png

 

 

If I change the formula to look for any value, for example "test123", the formatting does show up on the form view.  The only thing that does not work is blank fields on the form view.  Any advice?

1 Reply

@Shaune1215 Yeah, I have also observed this behavior in SharePoint list forms.

 

Microsoft show "-" by default for empty single line of text fields. Maybe because of that the formatting is not correctly shown on the list forms.

 

Try raising a support ticket with Microsoft directly and report this behavior: Get M365 Support - Online Support 


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.