1

I am having trouble to add a statement for if a value is null in my sharepoint list. Currently this is the code I have that is working:

{
     "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column- 
     formatting.schema.json",
     "elmType": "div",
     "txtContent": "@currentField",
     "style": {
              "color": "black",
              "background-color": "=if(@currentField <= @now - 31536000000, 
              '#ff9999',if(@currentField <= @now - 28944000000 && @currentField > @now - 
              31536000000,'#ffff99', 'white'))"
                }
 }

Date values are what is being stored in this column, what code do I need to add for ows that have no values to show up with a blue highlight?

1 Answer 1

0

In SharePoint JSON Formatting, you can check if date & time column is blank like:

Number(@currentField) == 0

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


For your requirements, use this JSON:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
        "color": "black",
        "background-color": "=if(Number(@currentField) !=0 ,if(@currentField <= @now - 31536000000,'#ff9999',if(@currentField <= @now - 28944000000 && @currentField > @now - 31536000000,'#ffff99','white')),'#0000ff')"
    }
}
1
  • 1
    Thank you for the help!
    – Brax
    Commented Jun 26, 2023 at 19:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.