Dependent values getting erased if we are using g_form.removeOption for onchange client script

SamiranD
Tera Contributor

I have two variables, request type and subrequest type. values of sub request type are dependent on request type. Now  I have added all the question choices for sub request type  and using g_form.removeOption to hide the values based on selected requested type value. But for the first selection of request type i am getting the desired sub request type values, but for subsequent slections i am not able to see any values in sub request type. 

Any one can help please

 

13 REPLIES 13

Sandeep Rajput
Tera Patron
Tera Patron

@SamiranD Ideally, you shouldn't be achieving via a client script. It should ideally be done via dependent value field in the choice list.

 

Screenshot 2025-01-28 at 8.02.13 PM.png

Once the dependent values on the subrequest type are defined then the choices would get updated depending up on the request type.

 

Hope this helps.

I am talking about variables in a catalog item not a field

@SamiranD Thanks for the clarification, for catalog items, you should instead try to use a Look up select box and use a reference qualifier to filter the data. Here is a post covering the same topic https://www.servicenow.com/community/developer-articles/solved-dependent-variable-on-catalog-item-us...

 

Hope this helps.

JenniferRah
Mega Sage

Can you share the script you are using to populate the subtype? I assume it's a catalog client script designed to run on change of type. If we see your script, we can possibly find where the issue is.