- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:06 AM
auto populate email id when name is selected from the reference field(sys_user)
Form fields
Name(reference from sys_user)
email( to be populate)
tried client script on variable set but its not working,
Kindly help with this simple script.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:10 AM
Here is an onChange catalog client script
Please update the variable names in the below script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var usr = g_form.getReference('USER_VARIABLE_NAME', callBack);
}
function callBack(usr)
{
g_form.setValue('EMAIL_VARIABLE_NAME', usr.email);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:10 AM
Here is an onChange catalog client script
Please update the variable names in the below script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var usr = g_form.getReference('USER_VARIABLE_NAME', callBack);
}
function callBack(usr)
{
g_form.setValue('EMAIL_VARIABLE_NAME', usr.email);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 10:15 AM
Perfect! I knew there had to be a simple solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:18 AM
Hi Senha,
Create a onchange client script on your Name field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var caller = g_form.getReference('your_name_field', getEmail); // doAlert is our callback function }
function getEmail(caller) { //reference is passed into callback as first arguments
g_form.setValue('your_email_field',caller.email,caller.email);
}
}
PS: you need to change the field names to yours.
Mark the answer as correct once it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 11:49 PM
answer is correct