- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2018 11:34 PM
Hi,
i have this catalog item with variables-
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2018 11:59 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2018 12:07 AM
Hi,
step1: for applicant variable add below code as shown;
Step2: write a clinet script for populate location as below
thank you.