Forum Discussion

Ikaika1070's avatar
Ikaika1070
Copper Contributor
Nov 14, 2023
Solved

Highlight row yellow when 30 days before Expiry Date and red when expired

I'm a newbie to everything SharePoint and need help highlighting all rows yellow in a SharePoint list item that is 30 days out from the Expiry Date and red when it expires.

 

I found this JSON code which does half of what I want to do but I'm not sure how to add the other condition to get the result I need.

 

Any help will be greatly appreciated.

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": "=if([$ExpiryDate] <= @now, 'sp-field-severity--severeWarning', '')"
}

 

  • Ikaika1070  the example below will change the row background to red if the date column, Arrival, is less than now but will change it to orange if the arrival is within the next 30 days:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
      "additionalRowClass": "=if([$Arrival] < @now(), 'ms-bgColor-red', if([$Arrival] >= @now() && [$Arrival] <= addDays(@now(),30), 'ms-bgColor-yellow', ''))"
    }

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP UK (and classic 1967 Morris Traveller driver)

2 Replies

  • Rob_Elliott's avatar
    Rob_Elliott
    Bronze Contributor

    Ikaika1070  the example below will change the row background to red if the date column, Arrival, is less than now but will change it to orange if the arrival is within the next 30 days:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
      "additionalRowClass": "=if([$Arrival] < @now(), 'ms-bgColor-red', if([$Arrival] >= @now() && [$Arrival] <= addDays(@now(),30), 'ms-bgColor-yellow', ''))"
    }

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP UK (and classic 1967 Morris Traveller driver)

    • Ikaika1070's avatar
      Ikaika1070
      Copper Contributor
      That worked perfectly! I understand the logic now! Thank you so much!!!

Resources