I have a SharePoint List. Two of the columns are "Due Date" and "Status". The Due Date column is obviously, populate with dates, with times turned off. The Status field is a choice field, formatted in pills and contains Queued, Work in Progress, On-Hold, Completed and Cancelled. If the Date is prior to the current day, meaning past due, AND the status is NOT Cancelled or Completed, I want to format the Due Date text. I would like it to be Centered, Bold and Red. I would also like to make it a slightly larger text, if possible, using font size like 8, 10, 12 ... so I can easily alter the code. I would like to keep the existing background color and also use hexadecimal code, #FF0000, to represent the red color, so I can easily tweak the color if needed.
1 Answer
Try this one and let me know
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if((@currentField < (@now - (86400000 *1))) && (([$Status]!='Cancelled') && ([$Status]!='Completed')) , '#FF0000', '')",
"font-size": "12px",
"font-weight": "bold",
"justify-content": "center"
}
}
