0

If current field (target closure date) is <= today AND Status = "Open"(This is drop down option), then text should display in red color.

I have tried with below JSON but no luck:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "debugMode": true,
    "txtContent": "@currentField",
    "style": {
        "color": "=if((@currentField = @now),if([$Status] == 'Open'), '#ff0000', '')" 
    }
}
0

Try Using && (AND) operator it will work perfectly for your scenario.

Try below code:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "debugMode": true,
    "txtContent": "@currentField",
    "style": {
        "color": "=if(@currentField <= @now && [$Status] == 'Open', '#ff0000', '')"
    }
}

Check the detailed article about the operators which are currently supported in JSON formatting:

Use column formatting to customize SharePoint - Operators.

0

Try below, below is working

   {
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if(@currentField == 'Open', if([$Target_x0020_Closure_x0020_Date] <= @now,'#ff0000',''),'')"
  }
}
  • it is not working as expected. it is for only currentfield – prasad Sep 3 at 5:29
  • you can use [$Status] to reference other fields.... – Siddharth Vaghasia Sep 3 at 6:28
  • { "$schema": "developer.microsoft.com/json-schemas/sp/v2/…", "elmType": "div", "debugMode": true, "txtContent": "@currentField", "style": { "color": "=if(@currentField == 'Open' && [$Target_x0020_Closure_x0020_Date] <= @now , '#ff0000', '')" } } – prasad Sep 3 at 6:38
  • The above mentioned JSON is working as expected. Thank you to all – prasad Sep 3 at 6:39
  • please check updated answer. – Siddharth Vaghasia Sep 3 at 6:44

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.