question

PatColan-5521 avatar image
0 Votes"
PatColan-5521 asked PatColan-5521 answered

Sharepoint Choice Field Multi-Select Options

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.

office-sharepoint-online
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.

CaseyYangMSFT-4714 avatar image
0 Votes"
CaseyYangMSFT-4714 answered CaseyYangMSFT-4714 edited

Hi @PatColan-5521,

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.



1.png (18.0 KiB)
1.png (37.0 KiB)
image.png (3.8 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.

PatColan-5521 avatar image
0 Votes"
PatColan-5521 answered CaseyYangMSFT-4714 commented

Thanks @CaseyYangMSFT-4714, 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.

· 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.

Hi @PatColan-5521,

I updated my answer, please check if this answer is helpful

0 Votes 0 ·
PatColan-5521 avatar image
0 Votes"
PatColan-5521 answered

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

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.