onChange Catalog Client Script setting Location # Field

Julia Howells
Giga Guru

I need to have an onChange client script on a catalog item populate another field.

The field 'Site Name' should populate 'Site Number' when Site Name is filled in. Site Name is a reference field to the cmn_location table, and on that table, there is a u_location_number field. This field is what would populate the Site Number field on the catalog item.

I am pretty sure I am missing a step in the script, but not sure where I should fix it. 

find_real_file.png

 

1 ACCEPTED SOLUTION

Musab Rasheed
Tera Sage
Tera Sage

Hello,

The way you are dot walking will not work, so either you have to use Glidereference or Glideajax, here is sample script for glidereference. Also change UI type to 'ALL'

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var gr = g_form.getReference('site_number_name', getData);

if(gr != '')

function getData(gr) 
{ 

           
 
            g_form.setValue('sit',gr.sit_location);

}
       
   
}

Also, try to follow no code approach as well

https://community.servicenow.com/community?id=community_article&sys_id=49deac8ddb92a010ab0202d5ca961967

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

5 REPLIES 5

dmathur09
Kilo Sage
Kilo Sage

Hi Julia,

Dot walking would not work here. I would suggest to use Catalog Data lookup Definition to accomplish this work as a no code approach.

https://community.servicenow.com/community?id=community_article&sys_id=96153c14db2dd010f7fca851ca96192b

Let me know in case you have any further queries

If you think my response is helpful for you? If yes, mark it as correct answer and close the loop so that it would help future readers as well.

Regards,
Deepankar Mathur