Auto populate one variable on a Catalog item based on the value of another variable

Olaf0816
Tera Contributor

Hi!

On my test catalog item, I have created two variables, one call 'Location' and the other called 'Sitecode'.    The 'Sitecode' value should automatically update when I select a value in the 'Location' variable.

I have created a custom table.

find_real_file.png

This is my test form.

 find_real_file.png

 

 

This are my catalog item variables.

find_real_file.png

This is my client script.

find_real_file.png

Unfortunately, it's not working. What am I doing wrong? Can someone help me please?

BR

Manfred

 

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update it as below:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var og = g_form.getReference('Location', callBackMethod);

}

function callBackMethod(og){

g_form.setValue('Sitecode', og.u_og_site_code);

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hello Ankur.

Unfortunately, that doesn't work either.

BR

Manfred

Hi,

Is the Location field a reference to that table?

Regards
Ankur

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

Subhojit Das
Kilo Guru

Hi,

May I know what is the field type of sitecode in location table?

Regards,

Subhojit