Aug 03 2020 08:59 AM
Hello All,
I'm trying to use 'Conditional formatting based on the value in a text or choice field (advanced)' in a SharePoint Online project tracking list and the formatting is not appearing on the list. I used the JSON from the Microsoft Docs article, 'Use column formatting to customize SharePoint,' and changed the names of the choice field names. I'm not sure what I'm doing wrong. I've used the view-formatting-schema as well and no change.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Closed', 'sp-field-severity--good', if(@currentField == 'Submitted', 'sp-field-severity--low', if(@currentField == 'Open', 'sp-field-severity--warning', if(@currentField == 'Potential RFI', '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 == 'Closed', 'CheckMark', if(@currentField == 'Submitted', 'Forward', if(@currentField == 'Open', 'Error', if(@currentField == 'Potential RFI', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
Thanks for any assistance!
Patti
Aug 07 2020 08:53 PM
Hi @PLove59, I just used the same json below and applied to the text and the choice field type, it works without any change. See the screenshot below and the json used.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Closed', 'sp-field-severity--good', if(@currentField == 'Submitted', 'sp-field-severity--low', if(@currentField == 'Open', 'sp-field-severity--warning', if(@currentField == 'Potential RFI', '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 == 'Closed', 'CheckMark', if(@currentField == 'Submitted', 'Forward', if(@currentField == 'Open', 'Error', if(@currentField == 'Potential RFI', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
Aug 09 2020 10:05 PM - edited Apr 17 2023 06:28 AM
Solution@PLove59 , Is there any invalid JSON error or any other error in browser's console while applying this JSON code. Also, make sure you are applying this JSON to correct column where the said choices in code are available correctly (even case-sensitivity of choices).
Also, if you are referencing any other columns (nothing that I see in above mentioned JSON) then make sure you are using their internal names in your code correctly. Follow this article to get the internal name of your SharePoint column: How to find the Internal name of columns in SharePoint Online?
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.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
Aug 11 2020 08:25 AM