g_form.removeOption not working as expected on onLoad client script

Shamir Mawji
Kilo Expert

Hi, I am trying to hide 2 question choice options that are not required temporariliy.

I am trying to use the g_form.removeOption but I cannot get this to work. I am not sure if this is because of what I am doing... 

I am using the below... where u_access_type is the question field and loss and profit are the value of the option.

function onLoad() {
g_form.removeOption('u_access_type', 'loss');
g_form.removeOption('u_access_type', 'profit');
}

Any help appreciated!

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shamir,

Did you use proper choice values for hiding i.e. profit and loss. check that once

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi

follow link: Removing/Disabling options

 

Please: Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.

Shamir Mawji
Kilo Expert

Hi Ankur,

Thanks for your reply. I think I am using the proper choice values... 

These are the values on the question choice for Profit. 

find_real_file.png

Thanks

Shamir 

 

Hi Shamir,

Can you try to add alert in that onLoad and check whether it is running?

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

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader