- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 05:46 PM
Awesome that worked perfectly! You just saved me tons of time. Appreciate it greatly!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 10:22 PM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 07:48 AM
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 08:29 AM
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
Enhance Knowledge NOW@ www.solutioningnow.com
http://www.solutioningnow.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 08:52 AM
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!