The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Hiding a choice value in a field

Luke James
Tera Contributor

Good Morning All, 

 

I am trying to hid a choice value in the contact_type field on the case table. Here is my script in an onLoad client script, and it is not working, any ideas? 

 

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.removeOption('contact_type', 'self-service');
 
}
1 ACCEPTED SOLUTION

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Luke James The same script working for me. Please verify it is 

1. You should only remove the option if it is not the currently-selected option when the form loads.

2. You can try to add alert in that onLoad and check whether it is running?

3.Is there any other onload or ui policy which shows that option. check that

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1641021

 

Regards,

Sid

View solution in original post

2 REPLIES 2

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Luke James The same script working for me. Please verify it is 

1. You should only remove the option if it is not the currently-selected option when the form loads.

2. You can try to add alert in that onLoad and check whether it is running?

3.Is there any other onload or ui policy which shows that option. check that

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1641021

 

Regards,

Sid

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Make sure that the ui type field on your client script is set to all

AnuragTripathi_0-1716546722687.png

 

Also, when you hide a choice type you have to be careful that is is not already selected, else it will be blank it out

So something like below

 

function onLoad() {
if(g_form.getValue('contact_type')!='self-service')
g_form.removeOption('contact_type', 'self-service');
 }

 

 

-Anurag