question

SueDowner-1207 avatar image
0 Votes"
SueDowner-1207 asked ElsieLu-MSFT commented

Conditional Formatting not working in SP List

Morning Community, I have a calculated field in my list which will show either a score (number) or FAIL when Compliance column = No. I'm trying to get the column to display as red when it is a FAIL (with a warning icon), else show a tick and the score.

My code below has the scores showing correctly, though the FAIL ended up with a tick and the word became invisible.

89854-fail.png

Help ... TIA

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

"elmType": "div",

"attributes": {

 "class": "=if(@currentField == 'FAIL', 'sp-field-total--severeWarning', 'sp-field-total--good') + ' ms-fontColor-neutralSecondary'"

},

"children": [

 {

   "elmType": "span",

   "style": {

     "display": "inline-block",

     "padding": "0 4px"

   },

   "attributes": {

     "iconName": "=if(@currentField == 'FAIL', ' ErrorBadge', 'CheckMark')"

   }

 },

 {

   "elmType": "span",

   "txtContent": "@currentField"

 }

]

}


office-sharepoint-online
fail.png (7.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SueDowner-1207 avatar image
0 Votes"
SueDowner-1207 answered ElsieLu-MSFT commented

Hi Forum - removing this post ... looked at a number of other answers (after posting :( ) and have chosen to use the built-in conditional formatting instead (which meets my purpose)

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Glad to hear that and thanks for sharing. :)

0 Votes 0 ·