The CreatorCon Call for Content is officially open! Get started here.

How to manipulate a field with the options of a multiple choice field?

RenomarioC
Tera Contributor

I have a doubt to do this, in my cenario i need for example:

RenomarioC_0-1752712316735.png

If the option in field Movimentação is Garantia, the choice "Desenvolvimento" need to be invisible..
I was trying with g_form.removeOption(); but this don´t work for field like Multiple Choice.

any help is welcome, thank you so much!!


1 ACCEPTED SOLUTION

Hi @RenomarioC ,

 

you create the onChange client script on the multiple choice type variable

ChaitanyaILCR_0-1752758858423.png

 

it's the basic script (enhance it as per your requirement)

here when a user try to select value tset3 the client script clears it and shows the message

 

add you logic in the (if condition when a value can be selected and when it should not be)

ChaitanyaILCR_1-1752758894764.png

 

I don't know you exact requirement but you can enhance it with this idea

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

9 REPLIES 9

Chaitanya ILCR
Mega Patron

Hi @RenomarioC ,

 

g_form.removeOption(), clearOptions(), addOptions() none of the work with Multiple choice type variables

 

you have to change it's type to select box 

 

you can try the script that is shared in the below thread by replacing with your variable name (but it only works in the native UI and won't work in service portals)

 

 

https://www.servicenow.com/community/developer-forum/remove-option-from-a-multiple-choice-variable-w...

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @Chaitanya ILCR 

I can't change for select box, i need to use multiple choice for do this because is a specification from this task..

You idea to how i can do this?
Seems me that choices in multiples choices don't have ID for do something with this, like remove option ou add...

Hi @RenomarioC ,

 

I can think of these options

 

1. you can use the script that shared in the above thread and force the users to use the catalog item in the native UI

 

2. you can create an onChange Client script on the Multiple choice type field and force them to select a different value based on the other variable selection (as soon as they select the choice you clear the value and display a message that choice cannot be selected or something do this until they select the correct choice (or in the message display which are valid options))

 

3. you can change the type to select box

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Thank you so much!!

I will folllow your instruction for do this, you can helpe me to create this OnChange, like is possible set default value pre-selected and send a info message if the user try change for other options?