Color Code SharePoint List Column Cells based on Text in the Column
I have a Teams / SharePoint list for tracking projects. I have a column on Choices which include the text “Red”, “Amber” and “Green”. When the user selects one, I want to set the background color of the cell accordingly. I would like to use theses specific colors, if possible.
Red (#D20303)
Amber(#cbb100)
Green(#12ae00)
Amber and Green are working, Red is not. I tried many different codes and nothing works. Here is my code …
{
“elmType”: “div”,
“txtContent”: “@currentField”,
“style”: {
“color”: “#fff”,
“padding-left”: “14px”,
“background-color”: {
“operator”: “?”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField”,
“Red”
]
},
“#D20303”,
{
“operator”: “?”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField”,
“Green”
]
},
“#12ae00”,
{
“operator”: “?”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField”,
“Amber”
]
},
“#cbb100”,
{
“operator”: “?”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField”,
“Yellow”
]
},
“”,
“”
]
}
]
}
]
}
]
}
}
}
What am I missing?
Thanks,
John
I have a Teams / SharePoint list for tracking projects. I have a column on Choices which include the text “Red”, “Amber” and “Green”. When the user selects one, I want to set the background color of the cell accordingly. I would like to use theses specific colors, if possible. Red (#D20303)Amber(#cbb100)Green(#12ae00) Amber and Green are working, Red is not. I tried many different codes and nothing works. Here is my code … {“elmType”: “div”,”txtContent”: “@currentField”,”style”: {“color”: “#fff”,”padding-left”: “14px”,”background-color”: {“operator”: “?”,”operands”: [{“operator”: “==”,”operands”: [“@currentField”,”Red”]},”#D20303″,{“operator”: “?”,”operands”: [{“operator”: “==”,”operands”: [“@currentField”,”Green”]},”#12ae00″,{“operator”: “?”,”operands”: [{“operator”: “==”,”operands”: [“@currentField”,”Amber”]},”#cbb100″,{“operator”: “?”,”operands”: [{“operator”: “==”,”operands”: [“@currentField”,”Yellow”]},””,””]}]}]}]}}} What am I missing? Thanks,John Read More