JSON Formatting Person Column
I have a SharePoint list in which only names of 5 people are possible in each row and column. Now I want to use JSON to design the list so that the cell background is displayed in a different color for each name. I tried the following:
"attributes": {
"class": "=if(@currentField.title == 'Vance, Adele', '#006666', if(@currentField.title == 'Wilber, Alex', '#AABBCC', if(@currentField.title == 'Langer, Martin', '#FFEEAA', if(@currentField.title == 'Lorenz, Merlin', '#BBEECC', 'sp-field-severity--blocked')))) + ' ms-fontColor-neutralSecondary'"
}
But this doesn't seem to be the right approach. Does anyone have an idea how I can implement this?
Hi, I have created an example with just one condition, but you can expand it by adding your own conditions.
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField.title", "style": { "background-color": "=if(@currentField.title == 'Diana Beginner', '#cc0000', '#00cc00')" } }