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

Remove Option for Catalog item valiable

senon
Tera Sage
Tera Sage

Hi expert!

I am trying to remove a choice from a catalog item variable.

I have written a client script to remove the choices with the following conditions, but it does not work.

●Variable 

Question 

VAR_A

Name t015

 

●Question choises 

Text test1(remove it) test2
Value 1 2

 

●Client Script

function onLoad() {
   g_form.removeOption('t015','1');
}

However, as shown in the image below, "test" is displayed.

find_real_file.png

 

How can I help you?

Best regard.

 

senon.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@senon 

Few things to check

1) UI Type - ALL

2) Are you using correct variable name and correct choice value

Can you try this script

function onLoad() {
   g_form.removeOption('t015',1);
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

shloke04
Kilo Patron

Hi,

In the script shown above, I don't see any specific condition on which you want to removed the choice option name "test1", so I will suggest in that case navigate to the choic list option for that field and simply mark the option as "Inactive  = True" which will solve the issue and you dont't need a script for this.

 

Still if you want to go with the help of scripts then few things to take care of like for example if this particular field is getting values from another field based on dependent concept, you need to look around that or another way to handle this might be clear all the options and then just add the option you want like for example the code mentioned below:

 

function onLoad() {
   g_form.clearOptions('t015');
   g_form.addOption('t015','1','Choice Label');

}

Hope this helps. Please mark the answer as helpful/correct based on impact.

 

Regards,

Shloke

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke