Client script dosn't work on workspace ITAM

ahmed-24
Tera Contributor

Hello; 

Hello i want to auto populate fields on asset form for the assigned to field ; but I have probléme on ITAM Workspace; My client script works on back office normaly  but it dosn't working on ITAM Workspace!

Have anyone an idea about this problem please! 

Thank you for answering me . 

  • Client script : on change

ahmed24_0-1765965777567.png

 

 

  • function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  •     if (isLoading || newValue === '') {
  •         return;
  •     }
  •  
  •     var ga1 = new GlideAjax('snowCsdmUtils');
  •     ga1.addParam('sysparm_name', 'getServiceFromUser');
  •     ga1.addParam('sysparm_userId', newValue);
  •  
  •     ga1.getXMLAnswer(function(response) {
  •         var result = response;
  •         g_form.setValue('u_service', result);
  •     });
  •     //----------
  •     var ga2 = new GlideAjax('snowCsdmUtils');
  •     ga2.addParam('sysparm_name', 'getDirectionFromUser');
  •     ga2.addParam('sysparm_userId', newValue);
  •  
  •     ga2.getXMLAnswer(function(response) {
  •         var result = response;
  •         g_form.setValue('u_direction', result);
  •     });
  •     //---------
  •     var ga3 = new GlideAjax('snowCsdmUtils');
  •     ga3.addParam('sysparm_name', 'getSirFromUser');
  •     ga3.addParam('sysparm_userId', newValue);
  •  
  •     ga3.getXMLAnswer(function(response) {
  •         var result = response;
  •         g_form.setValue('u_sir', result);
  •     });
  •  
  • }
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@ahmed-24 

so any reason to call 3 times the GlideAjax call?

Why not use single GlideAjax and return multiple values?

share your script include config screenshot

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hello @Ankur Bawiskar because i want to populate 3 fields as you can see ( direction , service and another custopm field

@ahmed-24 

you can call GlideAjax only 1 time and script include will return all the 3 values in JSON and then you can parse and set your form fields

Now coming to your point why it's not working in workspace? share your script include config screenshot

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Deepak Shaerma
Mega Sage
Mega Sage

Hi @ahmed-24 

1. Just set UI Type to "All".
Test it if not working then apply step 2

2. Combine your logic into one GlideAjax call using JSON.stringify (Server) and JSON.parse (Client). This is much faster and cleaner.



Happy to help! ‌‌
To help others in the community find this solution, kindly mark this response as the Correct Answer ‌‌ and Helpful‌‌.
Warm Regards,
Deepak Sharma
Community Rising Star 2025