2

I am trying to color code a Row based on a condition in a Modern List (SPO). It goes something like this:

In English: If ApprovalStatus = 'Pending' AND 'RequestDate' < [Today]-5 Then Row Color = 'Red'

This is what I have so far, but it does not work.

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if(AND[$ApprovalStatus] == 'Pending', [$RequestDate] < [Today]-5), 'sp-field-severity--severeWarning','')"
}

1 Answer 1

3

To do the comparison against the current date, you need to use the @now. Also, you need to calculate a date 5 days back from today. So, you need to subtract 5 days worth of milliseconds, (5 * 24 * 60 * 60 * 1000 = 432000000).

So, try using below JSON code:

{
    "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "additionalRowClass": "=if([$ApprovalStatus] == 'Pending' && [$RequestDate] < @now-432000000, 'sp-field-severity--severeWarning', '')"
}

References:

  1. Use view formatting to customize SharePoint
  2. SharePoint Online Custom Format View issue with @now and UK Date format
1
  • That worked! Thank You.
    – Bismarck
    Commented Jun 16, 2020 at 18:17

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.