Sharepoint Choice Field Multi-Select Options

Pat Colan 21 Reputation points
2021-10-04T18:30:24.76+00:00

I'm trying to format a multi-select choice field with JSON. Is there a way to get all of the available choices? for instance, you can retrieve the lookup value of a lookup field with:

"txtContent":"@currentField.lookupValue"

but I have a choice field, so I am looking for something like:

"txtContent":"@currentField.choices"

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,621 questions
0 comments No comments
{count} votes

Accepted answer
  1. CaseyYang-MSFT 10,321 Reputation points
    2021-10-05T06:05:10.853+00:00

    Hi @Pat Colan ,

    Per my research, you could use the following JSON codes.

    {  
       "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
       "elmType": "div",  
       "txtContent": "@currentField"  
    }  
    

    From this article Use column formatting to customize SharePoint: Just like number, text, and date fields, choice column formatting is one that places the value of the field inside a <div /> element.

    Update:

    Per my test, i didn't find out how to get all choice field with JSON. I suggest you create a flow as a workaround.

    My test flow:

    138155-1.png

    My test result:

    138090-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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 comments No comments

2 additional answers

Sort by: Most helpful
  1. Pat Colan 21 Reputation points
    2021-10-05T13:27:34.113+00:00

    Thanks @CaseyYang-MSFT , but I know I can extract the field value answers with your code, what I want is to pull all of the options available for the field.

    For instance, if a choice field has 4 options, and the user selects 2 of them, I want to be able to show all 4.

    User Answer:                         Available Options:  
                                                  Choice 1  
    Choice 2                                Choice 2  
                                                  Choice 3  
    Choice 4                                Choice 4  
    

    I just don't know how to pull the available options of the field.


  2. Pat Colan 21 Reputation points
    2021-10-06T23:05:32.197+00:00

    I appreciate all the effort! It seems like this should be easily accessible with JSON, but your workaround using flow does work. Thanks.

    0 comments No comments