Simple row color by lookup field

%3CLINGO-SUB%20id%3D%22lingo-sub-2166293%22%20slang%3D%22en-US%22%3ESimple%20row%20color%20by%20lookup%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2166293%22%20slang%3D%22en-US%22%3E%3CP%3EAll%20I%20am%20trying%20to%20do%20is%20color%20code%20the%20rows%20by%20the%20value%20of%20a%20Status%20lookup%20field.%20The%20documentation%20says%20this%20will%20work%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Frow-formatting.schema.json%22%2C%0A%20%20%22additionalRowClass%22%3A%22%3Dif(%5B%24Status%5D%3D%3D'Not%20Assigned'%2C'sp-field-severity--severeWarning'%2C%20'')%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20SharePoint%20complains%20that%20%22additionalRowClass%22%20is%20expecting%20an%20object.%20The%20schema%20for%20%22additionalRowClass%22%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%23definitions%2Fexpression%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20But%20it%20is%20difficult%20the%20determine%20what%20the%20attribute%20wants%20just%20looking%20at%20the%20schema.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can't%20find%20an%20example%20of%20what%20%22additionalRowClass%22%20wants%20to%20just%20change%20the%20row%20background%20color.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2171082%22%20slang%3D%22en-US%22%3ERe%3A%20Simple%20row%20color%20by%20lookup%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2171082%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288947%22%20target%3D%22_blank%22%3E%40smithme%3C%2FA%3E%26nbsp%3Bit's%20the%20schema%20that's%20causing%20the%20problem.%20This%20will%20work%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%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%22additionalRowClass%22%3A%20%22%3Dif(%5B%24Status%5D%20%3D%3D%20'Not%20Assigned'%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%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2171451%22%20slang%3D%22en-US%22%3ERe%3A%20Simple%20row%20color%20by%20lookup%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2171451%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288947%22%20target%3D%22_blank%22%3E%40smithme%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESeems%20you%20are%20using%20wrong%20JSON%20schema.%20You%20should%20use%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fview-formatting.schema.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fview-formatting.schema.json%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20%3CSTRONG%3Enot%3C%2FSTRONG%3E%20this%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Frow-formatting.schema.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Frow-formatting.schema.json%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20view%20formatting%2C%20refer%20below%20Microsoft%20official%20documentation%3A%3C%2FP%3E%3CP%3E%3CA%20title%3D%22View%20formatting%20-%20Apply%20conditional%20classes%20on%20rows%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fview-formatting%23apply-conditional-classes-on-rows%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EView%20formatting%20-%20Apply%20conditional%20classes%20on%20rows%3C%2FA%3E%3C%2FP%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20%26amp%3B%20%3CSTRONG%3ELike%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20to%20solve%20your%20issue.%20This%20will%20help%20others%20to%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20post%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3ELike%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2172021%22%20slang%3D%22en-US%22%3ERe%3A%20Simple%20row%20color%20by%20lookup%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172021%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F373269%22%20target%3D%22_blank%22%3E%40ganeshsanap%3C%2FA%3E%26nbsp%3B..which%20of%20course%20was%20what%20I%20demonstrated%20in%20my%20post%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2173469%22%20slang%3D%22en-US%22%3ERe%3A%20Simple%20row%20color%20by%20lookup%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2173469%22%20slang%3D%22en-US%22%3E%3CP%3EYes%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F174092%22%20target%3D%22_blank%22%3E%40RobElliott%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20wanted%20to%20add%20some%20explanation%20%26amp%3B%20%3CSTRONG%3Emainly%3C%2FSTRONG%3E%20the%20link%20to%20Microsoft%20official%20documentation%20for%20view%20formatting.%20So%2C%20that%20OP%20can%20validate%20the%20current%20JSON%20as%20well%20as%20refer%20to%20the%20documentation%20for%20any%20changes%2Fenhancements%20in%20future.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20you%20understand!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

All I am trying to do is color code the rows by the value of a Status lookup field. The documentation says this will work:

 

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

 

However, SharePoint complains that "additionalRowClass" is expecting an object. The schema for "additionalRowClass" can be found here. But it is difficult the determine what the attribute wants just looking at the schema.

 

I can't find an example of what "additionalRowClass" wants to just change the row background color.

 

4 Replies

@smithme it's the schema that's causing the problem. This will work:

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

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@smithme 

Seems you are using wrong JSON schema. You should use 

https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json.

 

And not this:

https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json

 

For view formatting, refer below Microsoft official documentation:

View formatting - Apply conditional classes on rows


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

@ganeshsanap ..which of course was what I demonstrated in my post :)

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

Yes @RobElliott.

 

I just wanted to add some explanation & mainly the link to Microsoft official documentation for view formatting. So, that OP can validate the current JSON as well as refer to the documentation for any changes/enhancements in future.

 

Hope you understand!