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

AshishKM
Kilo Patron
Kilo Patron

Hi,

user the user object in place of custom table name because you are taking that object as input parameter in populateDetails function.

 

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

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Harish KM
Kilo Patron
Kilo Patron

Hello @Thomas98 if your Servicenow is on Utah version and above you don't need client script to achieve this. You can use autoPopulate feature, check example below

https://www.servicenow.com/community/developer-articles/auto-populate-reference-data-in-service-cata...

Regards
Harish

Hi Harish, Yes, it will help. However, it will still be applicable only for Reference not for Lookup Select box.

I tot it's a reference field.

Regards
Harish

Ankur Bawiskar
Tera Patron
Tera Patron

@Thomas98 

getReference I believe won't work with lookup select box

Please use GlideAjax

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