Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Populate user location using default value

nicolemccray
Tera Expert

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');

 

1 ACCEPTED SOLUTION

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);
        }
    }
}

View solution in original post

15 REPLIES 15

Shashi Bhushan
Kilo Guru

Hi Nicole

Are you able to populate the location field ?