- 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
10-18-2018 12:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 07:08 AM
Hi Johan,
I tried to implement the same default value but not able to get the value auto populated. my reference table for location variable is "cmn_location" and i even tried with "sys_user" reference. Could you please suggest. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2018 08:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 08:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2019 11:40 PM
Hi Jenny,
Is your "Line Manager Approval" field of the type String or Reference? It should be Reference, pointing to the cmn_location table.