- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 10:39 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:36 PM
You need to have a Client Script as:
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue == '') {
- return;
- }
- var user = g_form.getReference('<<fieldname>>');
- g_form.setValue('u_user_manager', user.manager);
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:36 PM
You need to have a Client Script as:
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue == '') {
- return;
- }
- var user = g_form.getReference('<<fieldname>>');
- g_form.setValue('u_user_manager', user.manager);
- }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:46 PM
Hi Snowuser,
You can achieve this req with the help of Dot-Walking. Here is the more details.
http://wiki.servicenow.com/index.php?title=Dot-Walking
Alternatively you can use the below client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
if (newValue == '') {
g_form.setValue('u_user_manager', '');
return;
}
if (!g_form.getControl('u_user_manager'))
return;
var caller = g_form.getReference('caller_id', setManager);
}
function setManager(caller) {
if (caller)
g_form.setValue('u_user_manager', caller.manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 01:22 AM
Thanks all for the script. The scripts are working but only issue is I am getting sys_id of the manager in the field, not the name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 01:25 AM
snowuser11,
Check if the manager field is a reference field to user table. if not please change it like that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2015 01:28 AM
Make sure the manager is a reference field to the sys_user table.