question

sl23-4830 avatar image
0 Votes"
sl23-4830 asked AllenXu-MSFT commented

Sharepoint - Formatting a Column (JSON)


I have a sharepoint list, I want the field to go green when training has been completed and for the field to go red when it is empty. Could some please help?

141684-image.png


office-sharepoint-online
image.png (214.6 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

AllenXu-MSFT avatar image
0 Votes"
AllenXu-MSFT answered AllenXu-MSFT commented

Hi @sl23-4830 ,

To format a column based on its field value, please take a reference to the following JSON example:

 {
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
     "background-color": "=if((@currentField == 'Completed', '#00ff00', if(@currentField == '', '#ff0000', '#DDA0DD')"
     }
 }

141878-image.png

If you want format the color of another column based on the "training" column, please take a reference to the below JSON.

 {
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
     "background-color": "=if(([$training] == 'Completed', '#00ff00', if([$training] == '', '#ff0000', '#DDA0DD')"
   }
 }

141829-image.png



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.


image.png (9.7 KiB)
image.png (10.0 KiB)
· 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.

@sl23-4830 ,

Just checking how things are going on this thread. Is there any progress? Feel free to reply if you have any question.


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.

0 Votes 0 ·