Need Help with “Format View” feature in Modern List based on Condition
-
08-02-2021 - |
Domanda
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','')"
}
Soluzione
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:
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange