We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to change referenced tables on one reference field based on other dropdown values.

aastha3
Giga Contributor

I have a requirement where I have three variables   in service catalog

1. CI Type(select box) -> VM , Linux , ESX, JBOSS

2. CI Name (reference field)

3. Sys ID (single line text)

Now I want that whenever the CI type is changing the referenced table in CI Name   should change accordingly with their respective tables.

like for vm ->cmdb_ci_vm similarly for others as well.

My end result is to fetch selected ci name's sys id .

For changing reference field script include and onchange client script will be required .

for sysid fetch also onchange or onsubmit script will be required   . Not sure about this

Please help me with the correct code for my requirement .

Let me know if you need any further information.

1 ACCEPTED SOLUTION

Please replace-


var type=current.u_type;



with


var type=current.variables.u_type;



It should work now. Best of luck.


View solution in original post

26 REPLIES 26

Manoj Kumar16
Giga Guru

Then replace the var type=current.vm_type; with var type=current.vm_name; in the script and retest and check the logs


no no ... vm_name is value for CI Name where we used the javascript calling which has configuration table .Its the reference field


vm_type is value for CI Type which has dropdown values as vm ,hana,esx, etc.


Manoj Kumar16
Giga Guru

is it the value or the name ? Can you configure the dropdown variable and show me the name with the help of a screenshot ?


find_real_file.png




find_real_file.png



find_real_file.png





find_real_file.png


Please replace-


var type=current.u_type;



with


var type=current.variables.u_type;



It should work now. Best of luck.