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

Hi Alka, 

 

Yes, the client  callable is checked. 

 

I'm building this on a variable set and the client script if on the variable set. 

Fields in the variable set 

select_role 

description 

 

table I'm using on "select role" is " u_azure_roles

This is a custom table with 2 fields 

u_role, u_description 

 

Thomas98_0-1697636206014.png

 

 

Hello @Thomas98 

 

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

Hello @Thomas98 ,

Please change the variable name from --> 'var num' to 'var role' in line 5. This will fix your issue.