Forum Discussion
FabienGUILLAUME
Apr 15, 2025Copper Contributor
Pb formating columns
Hello,
I used JSON to format the columns of a list. It works fine when I'm in design mode on my list.
However, when I embed this list into a web page, from a Web Part, it no longer works. The formatting is removed.
Do you have any ideas on how to resolve this issue, please ?
Below is the JSON code of the column :
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Divers', 'sp-field-severity--good', if(@currentField == 'Note information', 'sp-field-severity--low', if(@currentField == 'Travaux', 'sp-field-severity--warning', if(@currentField == 'Organigramme', '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 == 'Divers', 'CheckMark', if(@currentField == 'Note information', 'Forward', if(@currentField == 'Travaux', 'Error', if(@currentField == 'Organigramme', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
1: Rendering the list in design mode
2: Rendering by adding the list to a web page
Thank you in advance for your help.
Sincerely,
Fabien
- grant_jenkinsSteel Contributor
I'd assume this is just a caching issue. Can you clear your browser cache and see if that fixes the issue?
- Rob_ElliottBronze Contributor
This is not going to be any help but your JSON is fine and worked immediately for me when I embedded the list in SharePoint page. So I really don't now what the problem is, perhaps someone else has an idea.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)- FabienGUILLAUMECopper Contributor
Hello,
Thank you for your answers.
What surprises me is that if I limit myself to making the font bold, or changing the text color or the font name, it works.
As soon as I try to add icons, it doesn't work.
Could this be due to the version of SharePoint?Fabien GUILLAUME