- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 05:18 AM
I would like to auto-populate a 'Location' field based on the person selected in the 'New Hire' field. Trying to do this using Default Value, but not working:
javascript:gs.getUser(current.variables.new_hire_name).getRecord().getValue('u_location');
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2018 04:59 AM
I was able to get this working by changing the variable type to 'reference', and using the following code:
function onChange(control, oldValue, newValue, isLoading) {
//Type appropriate comment here, and begin script below
var newHire = g_form.getValue('new_hire_name');
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', newHire);
user.query(setLocation);
function setLocation (user){
if ( user.next() ){
g_form.setValue('location_1', user.location);
g_form.setValue('location_2', user.location);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 05:24 AM
Hi
Try this :- gs.getUser(current.variables.new_hire_name).getDisplayValue("location").
Mark correct if it helps.
Regards,
Omkar Mone
www.dxsherpa.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 05:26 AM
javascript:gs.getUser(current.variables.new_hire_name).getRecord().getDisplayValue("u_location"); Please mark answer as correct or helpful. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 05:41 AM
I was able to get a location to populate using this:
javascript:gs.getUser(current.variables.new_hire_name).getRecord().getDisplayValue('location');
But it is populating MY location, and not the location of the person in the 'new_hire_name' field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2018 05:58 AM
hi
So please tell me where are you doing this ?