auto populate current user and its location

sp_18
Giga Contributor

Hi,

i have this catalog item with variables-

find_real_file.png

I want auto populate the Applicant's Name field with logged in user and auto populate the location field of the current user with onload action.

 

what will be the onload client script?

Thank you.

 

1 ACCEPTED SOLUTION

sashichand
Mega Expert

 

Hi,

To auto populate the Applicant's Name field with logged in user - While defining the variable, set the default value as javascript:gs.getUserID(); ------- This will give you the current logged in user.

To auto populate the location field of the current user with onload action.

write an onLoad script:

var id = g_form.getValue('applicant_name'); //variable name
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',id);
user.query();
if ( user.next() ) {
g_form.setValue('location', user.location);

g_form.getValue('requestor_manager', user.manager);
g_form.setValue('phone', user.mobile_phone); //to set the phone number.
g_form.setValue('emp_number', user.employee_number); // to set the employee number.

}

 

Hope this will be helpful?

 

Thanks,

Shashikant

View solution in original post

10 REPLIES 10

Vishal Khandve
Kilo Sage

Hi,

step1:  for applicant variable add below code as shown;

 

Step2: write a clinet script for populate location as below

 

thank you.