Removing Multiple choice options on catalog item in portal

samadam
Mega Sage

I am trying to disable certain multiple choice options on onload for catalog item.

Tried the below but did not work:

var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form; 
form.removeOption(<fieldName>, <choiceValue>);

and
g_form.removeOption(
<fieldName>, <choiceValue>);

Any ideas on how to get this working?
1 ACCEPTED SOLUTION

samadam
Mega Sage

Cannot do this for multi choice. Had to use Select box.

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron

Hi,

 

you can use this syntax to remove the option

g_form.removeOption('variableName', choiceValue);

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

samadam
Mega Sage

Used the same format, did not work. 

Hi,

Can you share the complete script and the choice values as well?

Regards
Ankur

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

Anil Shewale
Mega Guru

Hi

Make a catalog UI policy for that item that has the following script: 

if you want to remove some specific roles then you can use the following script by clicking on script option of 

Ui policy.

 

if(!g_user.hasRoles('role1','role2',......)){

g_form.removeOption('field', 'value');

}

 

Otherwise u directly use following syntax:

g_form.removeOption('Field_name', 'Choice_name');// Example

for more detail refer the following thread.

Removing or Disabling Choice List Options

https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-opt...

 

If it help mark helpful or correct 

Thanks and regards

Anil