I'm seeking assistance from someone knowledgeable in JSON or coding as this is not my area of expertise.
In my sharepoint online list, I have customized the display to show different colors based on the text content in each item. Now, I am looking to incorporate icons into the columns as well. For instance, if the status is "New", I want it to display the chosen color as well as a + icon from the Office UI Fabric.
Below are the two separate codes that I have utilized, both of which work independently. My goal is to combine them together seamlessly.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "=if(@currentField == 'Completed', 'CheckMark', if(@currentField == 'Draft phase', 'Forward', if(@currentField == 'Approval phase', 'Error', if(@currentField == 'On hold', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
{
"elmType": "div",
"style": {
"padding": "0 4px"
},
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"New"
]
}
]
},
"sp-css-backgroundColor-blueBackground07",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Draft phase"
]
}
]
},
"sp-css-backgroundColor-warningBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Approval phase"
]
}
]
},
"sp-css-backgroundColor-successBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Ready for upload"
]
}
]
},
"sp-css-backgroundColor-blockingBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Completed"
]
}
]
},
"sp-css-backgroundColor-neutralBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"On hold"
]
}
]
},
"sp-css-backgroundColor-errorBackground",
""
]
}
]
}
]
}
]
}
]
}
]
}
},
"txtContent": "@currentField"
}