Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update dependent choice list in incident when company changes?

frankh_
Giga Expert

I have a choice list that is dependent on the values of the company field in incident (specifically company.name) however, I cannot get the choice list to dynamically update   the choices whenever the person interacting with the form changes the value in the company field until the update / insert the record.   Is there a way to force the values to update whenever the user selects a new value for the company field?

I think it has to be some form of client script using GlideForm - but I can't figure out what.   Any help would be greatly appreciated.

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Francis,



Please refer addoption or removeoption choice here.


Client Scripts - ServiceNow Wiki


Hello Pradeep,

 

Any idea about the updateChoiceList_u_business_sub_service();, where u_business_sub_service is the field name in which we have to display the values in the drop down.

frankh_
Giga Expert

Pradeep - I am not quite understanding.   I created a choice list - lets call it "u_products" and I want want a different list of products to display in a drop down dependent on the value of the company field.   I don't want to add / subtract individual items - I have over 80 companies.   So for example - if the users is in an incident and selects "fruit growers" for his company then I want the choices to be "apples", "pears", "oranges" - but if the user selects "butcher" I want the choices to be "beef", "pork", "chicken" - so I created the choice list (u_products) dependent on company.name, type= string with choices like so:



label                             value                             dependent


apples                   apples                             fruit_growers


pears                   pears                                       fruit_growers


oranges         oranges                             fruit_growers


beef                   beef                                       butcher


pork                   pork                                       butcher


chicken         chicken                             butcher



But - if I create a new record it displays no choices until I select "butcher" or "fruit grower" and insert the record - then the choices don't change unless I update the record.



Is this because company is a reference field or should it always operate this way?   I haven't played too much with choice lists with dependent values before.


frankh_
Giga Expert

I figured out my problem - it is because I dot walked down to company.name.   Apparently I have to stay up at "company" which means I have to use the sysID of the record for dependent value.   That is going to be painful.