Question

So I have a SharePoint list with a column called modified. I used the following code to change the rows colors based on when it was last modified which works fine:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now - 86400000, 'sp-field-severity--blocked', if([$Modified] < @now && [$Modified] >= @now - 259200000, 'sp-field-severity--warning' , ''))"
}

However, now I want it to be a dark grayish color instead of red. I have tried many different things, but cannot get it too work for some reason.

Was it helpful?

Solution

Try something like below:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now - 86400000, 'ms-bgColor-gray120', if([$Modified] < @now && [$Modified] >= @now - 259200000, 'sp-field-severity--warning' , ''))"
}

This will apply ms-bgColor-gray120 class for first condition ([$Modified] < @now && [$Modified] >= @now - 86400000).

Similarly, you can apply any of the predefined classes given in below links as per your requirements:

  1. Predefined classes
  2. Reusable SharePoint Online Classes for Modern UI
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top