Forum Discussion
Configure conditional formatting for SharePoint list gallery view
- Nov 16, 2021
Hey everyone,
I've resolved this thanks to https://twitter.com/techan_k/status/1457664410042785802 on Twitter!
Just writing out the solution on here as well so it's easy to follow for anyone else.
From the class section, delete the ms-bgcolour value but keep the rest of the values as that gives the card its look and feel!
Add the following style value in between elmType and attribute section. I've included the code below to make it easier to copy and paste in. Decide on the colours you would like! Add additional if values if more than two are required. The last hex colour code is an else colour if your values don't match any of your if statements.
"style": { "background-color": "=if ([$ColumnName] == 'Nintex' , '#F5F9FD' , if ([$ColumnName] == 'Oracle' , '#EBF9EC' , '#FFF1EF'))" },
Hey everyone,
I've resolved this thanks to https://twitter.com/techan_k/status/1457664410042785802 on Twitter!
Just writing out the solution on here as well so it's easy to follow for anyone else.
From the class section, delete the ms-bgcolour value but keep the rest of the values as that gives the card its look and feel!
Add the following style value in between elmType and attribute section. I've included the code below to make it easier to copy and paste in. Decide on the colours you would like! Add additional if values if more than two are required. The last hex colour code is an else colour if your values don't match any of your if statements.
"style": {
"background-color": "=if ([$ColumnName] == 'Nintex' , '#F5F9FD' , if ([$ColumnName] == 'Oracle' , '#EBF9EC' , '#FFF1EF'))"
},
xeno85The If conditional is not work for me. All backgrounds are defaulting to #FFF1EF as per your example. I have tried a straight If statement as the choice is YES or NO but it continues to default to the null. any suggestions. The yes / no is a calculated field in the list. Ant suggestions?
- ChuckisanimNov 19, 2022Copper ContributorBasic error - have to use internal Field name!
- ganeshsanapNov 21, 2022MVP
Chuckisanim Yes, JSON formatting works with internal name of columns. So, you have to use the internal name for all the columns you are referring in your JSON.
Check this to get internal name of your column: How to find the Internal name of columns in SharePoint Online?
Please consider giving a Like if my post helped you in any way.
- RybanShoMay 18, 2023Copper ContributorHi, I am getting the same issue as above with the formatting only showing the final colour value. My column/internal name is 'Status', is there something wrong with using this term?