2

I have two columns: "LFR sign" and "Filing".

I would like to:

  • If the "LFR sign" is not empty -> "Filing " becomes red if it's empty

I am sure this is quite simple for you guys but I am struggling with this since this morning.

5
  • Are you using SP online or 2019? Do you mean that you have to columns: LFR sign and Filing? What is the data type of this columns? Also, can you please explain the conditions in detail? maybe you can attach the screenshot of list view (to see what are the column names and how the data is stored) and expected output you want? – Ganesh Sanap Jan 11 at 16:48
  • Hello, yes I'm using SP online. Yes I have two columns, LFR sign and filing, the two columns contain dates. I would like to have the Filing column cetto to become red if LFR sign is not empty and Filing column is empty. – Anto Jan 12 at 8:38
  • 1
    Check my updated answer for JSON code using date fields. let me know if it works for you. – Ganesh Sanap Jan 12 at 9:47
  • Thank you Ganesh, it works now! – Anto Jan 12 at 10:12
  • 1
    Please don't comment thank you as an answer. Upvote(^) and accept my Answer as it helped you. – Ganesh Sanap Jan 12 at 10:29
2

As per my understanding you want set the color of "Filing" column cell to red if (Correct me if I am wrong):

  1. LFR sign column is not empty AND
  2. Filing column is empty

Then try adding below JSON to "Filing" column:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "style": {
        "color": "=if([$LFRSign] != '' && @currentField == '', 'red' , '')"
    },
    "txtContent": "@currentField"
}

Note: Replace LFRSign with the correct internal name of your "LFR Sign" column.

Reference: Use column formatting to customize SharePoint


Update from Comments:

For date fields, try below code:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "attributes": {
        "class": "=if(Number([$LFRSign]) != 0 && Number(@currentField) == 0, 'sp-field-severity--blocked' , '')"
    },
    "txtContent": "@currentField"
}

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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