Catalog client script help

Thomas98
Tera Expert

Hi All, 

 

Can someone please help me with the catalog client script?

 

I have two field 

1) select_the_type_of_access_required 

2)  u_description 

I need an on change catalog item script 

when I select the "type of access" the description should auto fill itself. 

Custom table name " u_Azure_role

 

I have something in place but it wont work 😞 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }var user = g_form.getReference('select_the_type_of_access_requireds', populateDetails);

function populateDetails(user) {
    g_form.setValue('description',u_azure_roles.u_description);
}
}

 

 

 

 

3 ACCEPTED SOLUTIONS

Harsh_Deep
Giga Sage
Giga Sage

Hello @Thomas98 ,

 

Is select_the_type_of_access_requireds a reference field? 

If so, replace

 

g_form.setValue('description',u_azure_roles.u_description);

with

g_form.setValue('description',user.u_description);

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

View solution in original post

Harsh_Deep
Giga Sage
Giga Sage

Hello @Thomas98 

You have to use Script Include Call using client script-

 

https://www.servicenow.com/community/developer-articles/how-to-call-script-include-from-client-scrip...

 

Please open the above link and complete your requirement.

 

Please mark correct answer and helpful for others if it helps you
Thanks,

View solution in original post

Hello @Thomas98 

 

In line number 7th you are passing role but you haven't defined role anywhere.

View solution in original post

17 REPLIES 17

Jaspal Singh
Mega Patron
Mega Patron

hi Thomas,

Is select_the_type_of_access_requireds a reference field? 

If so, replace

g_form.setValue('description',u_azure_roles.u_description);

with

g_form.setValue('description',user.u_description);

Hi Jaspal. 

 

Hope you are doing well. The variable is a lookup select box. Can this work with look-up select box? 

I tried your solution with a reference variable and it worked. 

 

 

Hi Thomas,

If you want to keep it as lookup selectbox you will need to use Script include and Client Script to get it work. If reference works, then I suggest to use it as is.

Harsh_Deep
Giga Sage
Giga Sage

Hello @Thomas98 ,

 

Is select_the_type_of_access_requireds a reference field? 

If so, replace

 

g_form.setValue('description',u_azure_roles.u_description);

with

g_form.setValue('description',user.u_description);

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.