0

I'm trying to use the in-built tools to format a row in SharePoint online.

It is simple, I want it to highlight the row red when the due date is in the past AND another column value has been set. I use the row formatting to achieve this, but it still picks up blank dates and highlights them red.

How can I get it to ignore empty dates?

Here is the code being used:

{
  "$schema": https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json,
  "additionalRowClass": {
    "operator": ":",
    "operands": [
      {
        "operator": "&&",
        "operands": [
          {
            "operator": "<",
            "operands": [
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "[$Expires]"
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "operator": "Date()",
                "operands": [
                  {
                    "operator": "toDateString()",
                    "operands": [
                      {
                        "operator": "Date()",
                        "operands": [
                          "@now"
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "operator": "==",
            "operands": [
              "[$ExpiredDocumentUpdated]",
              "No"
            ]
          }
        ]
      },
      "sp-css-backgroundColor-BgDustRose sp-css-color-DustRoseFont",
      ""
    ]
  }
}

1 Answer 1

1

In JSON Formatting, you can check if Date & Time column is blank like:

Number([$Expires]) == 0

You can find other ways to check if date & time column is empty or not at: SharePoint JSON formatting: Check if date & time column is blank/empty

GitHub sample for reference: Formatting a column when a date column is blank


For your scenario, try using this JSON:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "additionalRowClass": "=if(Number([$Expires]) !=0 && [$Expires] < @now && [$ExpiredDocumentUpdated] == 'No', 'sp-css-backgroundColor-BgDustRose sp-css-color-DustRoseFont', '')"
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.