AutoPopulate a reference field based on another reference both fields referring same table

Community Alums
Not applicable

Need to auto populate application business unit which is a reference field referring (cmdb_ci_business_app) depending on the business application field which is also a reference field also referring to (cmdb_ci_business_app) table on a catalog form.

Variable 1: Business Application (Reference - cmdb_ci_business_app)

variable 2: Application business unit(reference-cmdb_ci_business_app)

tried the autopopulate option on the variable it is populating on form level but on ritm its clearing the value.

written a script include and onchange client script also

able to get the value from script include but not able to set on the field . Its setting the value and clearing immediately 

please help

1 ACCEPTED SOLUTION

@Community Alums 

For this case you can use 2nd variable as string type and populate the Business unit via onChange client script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Community Alums
Not applicable

tried this but its not working

You also need to change the reference table on the 'application_business_unit' variable to the 'business_unit' table instead of cmdb_ci_business_app.

@Community Alums 

I didn't get the logic of both variables referring to same table

Since both are referring to same table and 1 table can have only 1 display value field, both the variables will show the same value

2nd variable should be of string type and then your script will work fine and make sense to show the name

At 1st place why to have 2 variables but?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

in the first variable we are populating the application name where as in variable 2 we need to populate the business unit of the application name selected in variable 1

@Community Alums 

but both variable are referring to same table and both the variables will show same display value when selected or populated

How does it solve your purpose of showing business unit name of the app selected in variable 1

Please share some screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader