- 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-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:06 AM
Thanks 🙂
its working !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 05:36 PM
Running a GlideRecord query on client scripts isn't advisable, use a ScriptInclude instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2018 12:08 AM
To auto populate logged on Users Location, you can use the following Default Value in the Variable:
javascript:gs.getUser().getRecord().getValue("location");