Forum Discussion

Yarrah's avatar
Yarrah
Copper Contributor
Jan 03, 2020
Solved

Column Formatting for Status column not working

I have used this method in the past and everything work just fine. I am not sure why it isn't working now. the following JSON displays the icons properly but not the colors: 

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Approved', 'sp-field-severity--good', if(@currentField == 'Pending', 'sp-field-severity--low', if(@currentField == 'Closed', 'sp-field-severity--warning', if(@currentField == 'Rejected', 'sp-field-severity--severeWarning'))))"
},
"children": [{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "=if(@currentField == 'Approved', 'CheckMark', if(@currentField == 'Pending', 'Forward', if(@currentField == 'Closed', 'Error', if(@currentField == 'Rejected', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}

 

 

Can someone tell me what I'm doing wrong?

  • Yarrah 

    Use this it should work

     

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "attributes": {
    "class": "=if(@currentField == 'Approved', 'sp-field-severity--good', if(@currentField == 'Pending', 'sp-field-severity--low', if(@currentField == 'Closed', 'sp-field-severity--warning', if(@currentField == 'Rejected', 'sp-field-severity--severeWarning', 'sp-field-severity--blocked')))) + ' ms-fontColor-neutralSecondary'"
    },
    "children": [
    {
    "elmType": "span",
    "style": {
    "display": "inline-block",
    "padding": "0 4px"
    },
    "attributes": {
    "iconName": "=if(@currentField == 'Approved', 'CheckMark', if(@currentField == 'Pending', 'Forward', if(@currentField == 'Closed', 'Error', if(@currentField == 'Rejected', 'Warning', 'ErrorBadge'))))"
    }
    },
    {
    "elmType": "span",
    "txtContent": "@currentField"
    }
    ]
    }

4 Replies

Resources