Hi @Mark Gorelyk ,
Apply below JSON code to your choice columns:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(@currentField == 'Normal', 'sp-css-backgroundColor-BgGold', if(@currentField == 'Bad', 'sp-css-backgroundColor-BgCoral', if(@currentField == 'Good', 'sp-css-backgroundColor-BgMintGreen', '')))"
}
}
Test result on my end:
You can add above JSON code to a column using advanced mode or using PnP PowerShell below:
$SiteURL = "https://contoso.sharepoint.com/sites/test"
$ListName="Config"
$FieldName="choice" #Internal Name
$JsonFormat = @"
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(@currentField == 'Normal', 'sp-css-backgroundColor-BgGold', if(@currentField == 'Bad', 'sp-css-backgroundColor-BgCoral', if(@currentField == 'Good', 'sp-css-backgroundColor-BgMintGreen', '')))"
}
}
"@
Connect-PnPOnline -Url $SiteURL -Interactive
$Field = Get-PnPField -Identity $FieldName -List $ListName
$Field | Set-PnPField -Values @{CustomFormatter = $JsonFormat}
If you want to batch apply this JSON code to all your choice columns at once, I'm afraid it is impossible. As an alternative, you can go to Site settings > Site columns > Create a site choice column > add JSON code to Colnmn Formatting section. Next time you add this site choice column to lists/libraries, you won't need to add JSON code to them manually again and again.
----------
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.