Awesome that worked perfectly! You just saved me tons of time. Appreciate it greatly!


Hi Bhadley and Justin,



Since User field is of Reference type, no need to use the GlideRecord function.


Use GetReference function to fetch the user details from the form.



function onChange(control, oldValue, newValue, isLoading) {


userObject = g_form.getReference('user_field');




g_form.setValue('u_manager_field', userObject.manager);


g_form.setValue('u_last_name', userObject.last_name);


g_form.setValue('u_whatever', userObject.field_on_sys_user);  




}


You are absolutely correct!   I tend to do things the way I was introduced to them, but the way you describe is valid and even better...because it is less code!!


Hi Bhadley,



Just an addition to the above solution given by Subramanya, the getReference() is actually a synchronous server call which halts the client end until the response comes from the server. Where as if you use the same with a call back method (GlideForm (g form) - ServiceNow Wiki), the other client end scripts won't be halted due to this call since it's asynchronous which improves the client side performance a lil bit.



Ex:


function onChange(control, oldValue, newValue, isLoading) {


userObject = g_form.getReference('user_field',setUserInfo);


}



function setUserInfo(userObject){


g_form.setValue('u_manager_field', userObject.manager);


g_form.setValue('u_last_name', userObject.last_name);


g_form.setValue('u_whatever', userObject.field_on_sys_user);  


}



Please mark answer as correct/helpful, if it was really helpful.



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/


I love Service-Now just for the fact that there are always multiple ways to accomplish something. Thank you for all your help, the solutions work like a charm!