1

I would like to change the text in a field based on the choice of the same field:

When text Green choice selected, it will be displayed as a big Green dot, so goes to amber and red.

Can it be done using JSON?

1
  • What are the choices/options for your choice field? – Ganesh Sanap May 27 at 14:30
1

Use below JSON code:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if(@currentField == '', '', '•')",
    "style": {
        "color": "=if(@currentField == 'Amber', '#FFBF00', @currentField)",
        "font-size": "5em"
    }
}

Choice column settings:

enter image description here

Output:

enter image description here

Documentation: Use column formatting to customize SharePoint


Note:

  1. You can adjust the font-size & the color codes (Hex) as per your requirements.
  2. Here I have added the choices same as the color name. So, I have used @currentField in else block of if condition in color property.

If you have different choices, you can change it like:

"color": "=if(@currentField == 'In Progress', '#FFBF00', if(@currentField == 'Not Started', 'red', if(@currentField == 'Completed', 'green', '')))",
1
  • Please Upvote(^) and accept as an Answer if it helped you in any way & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. – Ganesh Sanap Jul 21 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.