JSON to format rows in SharePoint List

%3CLINGO-SUB%20id%3D%22lingo-sub-1753222%22%20slang%3D%22en-US%22%3EJSON%20to%20format%20rows%20in%20SharePoint%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1753222%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3EFirstly%20thank%20you%20in%20advance%20for%20any%20help%20anyone%20can%20provide%20on%20this%2C%20it's%20greatly%20appreciated.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EI%20thought%20this%20would%20be%20a%20simple%20one%20however%20I%20just%20can't%20understand%20why%20it's%20not%20working.%26nbsp%3B%20I'm%20new%20to%20JSON%20and%20it's%20just%20not%20going%20in%20my%20head%20at%20the%20moment.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20large%20SharePoint%20list%20which%20list%20tools%20that%20require%20calibration.%26nbsp%3B%20I%20would%20like%20to%20make%20rows%20highlight%20red%20if%20they've%20missed%20their%20calibration%2C%20(which%20I%20can%20get%20to%20work%20using%20the%20wizard)%2C%20and%20also%20make%20them%20highlight%20yellow%20if%20they're%20a%20month%20away%20from%20calibration%2C%20(which%20I%20can't%20do).%26nbsp%3B%20The%20wizard%20does%20not%20support%20this%20second%20option%2C%20so%20I%20have%20to%20head%20to%20JSON.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGoing%20from%20Microsoft%20instructions%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fview-formatting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUse%20view%20formatting%20to%20customize%20SharePoint%20%7C%20Microsoft%20Docs%3C%2FA%3E)%20I%20should%20be%20able%20to%20use%20this%20to%20make%20it%20work%2C%20however%2C%20if%20I%20use%20it%2C%20it%20turns%20everything%20red%2C%20unlike%20the%20wizard%20which%20did%20at%20least%20get%20the%20overdue%20items%20correct%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fview-formatting.schema.json%22%2C%0A%20%20%20%22additionalRowClass%22%3A%20%22%3Dif(%5B%24Next_x0020_Calibration_x0020_Date%5D%20%26lt%3B%3D%20%40now%2C%20'sp-field-severity--severeWarning'%2C%20'')%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20in%20a%20nutshell%2C%20why%20would%20this%20turn%20everything%20red%2C%20when%20it%20shouldn't%2C%20I'm%20guessing%20it%20could%20be%20something%20data%2Ftime%20format%20related%20or%20the%20fact%20that%20the%20'Next%20Calibration%20Date'%20field%20is%20a%20calculated%20field%2C%20but%20again%20it%20did%20work%20the%20the%20wizard%20-%20and%20secondly%2C%20how%20could%20I%20add%20another%20rule%20to%20this%20that'll%20make%20items%20yellow%20if%20they're%20a%20month%20away%20from%20calibration%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOnce%20again%20thank%20you%20for%20any%20help%20that%20anyone%20can%20offer.%26nbsp%3B%20It%20looks%20to%20me%20like%20it%20should%20be%20simple%2C%20but%20my%20head%20is%20starting%20to%20explode%20from%20reading%20tutorials%20and%20not%20getting%20anywhere%20with%20it.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1753222%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Hi all,

Firstly thank you in advance for any help anyone can provide on this, it's greatly appreciated.  

I thought this would be a simple one however I just can't understand why it's not working.  I'm new to JSON and it's just not going in my head at the moment.

 

I have a large SharePoint list which list tools that require calibration.  I would like to make rows highlight red if they've missed their calibration, (which I can get to work using the wizard), and also make them highlight yellow if they're a month away from calibration, (which I can't do).  The wizard does not support this second option, so I have to head to JSON.

 

Going from Microsoft instructions (Use view formatting to customize SharePoint | Microsoft Docs) I should be able to use this to make it work, however, if I use it, it turns everything red, unlike the wizard which did at least get the overdue items correct:

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

 

So in a nutshell, why would this turn everything red, when it shouldn't, I'm guessing it could be something data/time format related or the fact that the 'Next Calibration Date' field is a calculated field, but again it did work the the wizard - and secondly, how could I add another rule to this that'll make items yellow if they're a month away from calibration?

 

Once again thank you for any help that anyone can offer.  It looks to me like it should be simple, but my head is starting to explode from reading tutorials and not getting anywhere with it. 

 

Thank you again.

0 Replies