Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Michael Jones -
Giga Sage

If this is in the Service Portal, make sure that your client-script has a UI Type selected of either All, or Mobile/Service Portal. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

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

I did not know to set the UI type to "ALL".

Now, This script is working.

 

Thank you Ankur!

Hello Ankur, I tried the same. But when case gets created the category field is still visible in drop down. Can you please help me on this.