g_form.removeOption() is not working for a Catalog Client Script variable field

Saurabh8
Kilo Expert

Hi Team,

* I have created a variable for a record producer which is referring to "sys_choice" table and populating it in the front end

* I have created a onChange Catalog Client Script to remove couple of choices based what I select from the drop down, for the previous variable

Unfortunately the g_form.removeOption() method which I am using is not working at all!

Can someone please guide me as to what is the issue? I have also tried with g_sc_form.removeOption() but isn't working.

Attached is the screen shot for your reference.

Thanks and Regards

Saurabh

1 ACCEPTED SOLUTION

Glad! You can mark an answer as correct and helpful if it solved your query. So that it benefits future visitors as well.

 

Regards,
Sumanth

View solution in original post

11 REPLIES 11

Hey Sumanth,

Worked! I just had to select the "Type" as "Select Box" for the variable field instead of "Reference". It's working as expected. Thank you!

Regards

Saurabh

Glad! You can mark an answer as correct and helpful if it solved your query. So that it benefits future visitors as well.

 

Regards,
Sumanth

Allen Andreas
Administrator
Administrator

Hello,

If you're trying to filter values from a reference field, you'd need to use a reference qualifier to do so.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hey Allen,

Thank you for your guidance. I just changed the type to "Select Box" and it worked.

Regards,

Saurabh

Harish KM
Kilo Patron
Kilo Patron

Hi g_removeOption() will not work for reference fields. You need to use reference qualifier to restrict the values. You need a script include to filter the records and call the Script include using reference qual

example here

https://community.servicenow.com/community?id=community_article&sys_id=8ffacb6ddb18f010414eeeb5ca9619aa

Regards
Harish