0

I have a document library with a deadline column and a status column. If the deadline expires, the date will be red (see code). Now, additionally, when the task status is closed, the date should turn black again. Activity status is only open and closed. How can i customize the Code? Thank you all!

{

   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
      "color": {
         "operator": "?",
         "operands": [
            {
               "operator": "<=",
               "operands": [
                  "[$Deadline]",
                  "@now"
               ]
            },
            "#ff0000",
            ""
         ]
      }
   }
}

Many Greetings Christian

1

Here is the JSON Formatting for your case:

{
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "color": {
      "operator": "?",
      "operands": [
        {
          "operator": "&&",
          "operands": [
            {
              "operator": "!=",
              "operands": [
                "[$Status]",
                "closed"
              ]
            },
            {
              "operator": "<=",
              "operands": [
                "[$Deadline]",
                "@now"
              ]
            }
          ]
        },
        "#ff0000",
        ""
      ]
    }
  }
}

Please mark as answer if it is the desired solution for you.

  • Thanks for that Code! sure that this Code works? when i press F5 it have the same "red"-Colour – CPTawesome Nov 5 '18 at 14:21
  • that works for textfields but not for a dropdownlist right?! – CPTawesome Nov 5 '18 at 14:52
  • It works for dropdown and date both. – harshal gite Nov 5 '18 at 14:55
  • Check the spelling and case of "closed" with your dropdown options. They should match. And your deadline should be a date column. Only then it will satisfy a condition with @now – harshal gite Nov 5 '18 at 14:56

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.