Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Client script onChange

snowuser111
Kilo Guru

Hi,

Can anyone help please.

I have a reference field(sys_user) in incident . When a user is selected automatically the other field (u_user_manager) should populate the manager of the user.

Thanks

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

You need to have a Client Script as:



  1. function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  2.     if (isLoading || newValue == '') {
  3.           return;
  4.     }
  5.     var user = g_form.getReference('<<fieldname>>');
  6.     g_form.setValue('u_user_manager', user.manager);
  7.    
  8. }

View solution in original post

17 REPLIES 17

manager is reference to sys_user table.


Make sure display value is true..for manager field-->dictionary-->display value


Regards
Harish

Hi harish,



I tried changing Display value to true for manager but it seems the name is getting changed to false. and vice versa.


Hai Pradeep!



i had fallowed the same thing but i want to refer user photo from incident table, based on caller name.


Harish KM
Kilo Patron
Kilo Patron

Hi,



There can be only one value marked as true.


Regards
Harish