How to use client scripts from Native UI to Service operations workspace

VISWANATH KAMAL
Tera Contributor

I need to get caller loaction for the caller in the incident table.We have this related client script in Native  UI after changing the UI type to All still the location is not auto populated.

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

Hi @VISWANATH KAMAL ,
I trust you are doing great.

Here's an example solution:

  1. Open the incident table in ServiceNow Native UI.
  2. Navigate to the client script section and locate the related client script.
  3. Edit the script and ensure the UI type is set to "All" so that it functions correctly across different user interfaces.
  4. Add the following code snippet to retrieve the caller's location and populate it automatically:
function onLoad() {
   var callerId = g_form.getValue('caller_id');
   if (callerId) {
      var callerGr = new GlideRecord('sys_user');
      if (callerGr.get(callerId)) {
         var location = callerGr.getValue('location');
         g_form.setValue('location', location);
      }
   }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

6 REPLIES 6

After changing the UI type to All then also it is not working

Samakshi Chamol
Tera Contributor

Hey Viswanath...Hope you are doing well, I am facing the same issue, were you able to resolve yours?