Populate the email and phone of selected user in catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 03:47 AM - edited 02-03-2023 03:50 AM
Hi All,
I have requirement, like item variables are 'Register user, email and phone'. Register user variable is reference variable pointing to custom user table (note: not sys_user table). Custom User table has 'email' and 'phone' fields. In the portal, when I select the user then email and phone values should auto populate. I am trying with client script, it is not populating the values.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var req_for = g_form.getValue('requestor');
alert(req_for);
var details = new GlideRecord('u_users');
details.addQuery('sys_id', req_for);
details.query();
while (details.next()) {
alert('hello');
g_form.setValue('email', details.email);
alert(email);
}
}
Can any one help on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 09:22 AM
The "new" right way to do this is to use the "Auto-populate" functionality available since Utah release.
In your variable form, you have a tab "Auto-populate" with 3 fields:
Dependent question : Choose the reference variable (in your case "Requestor")
Reference : filled automatically with the related table (in your case, sys_user)
Dot walk path : Choose the field that contains the value you want to populate (in your case, Requestor.Email)
More information here.
No need to script anymore 😉
If usefull, please mark as helpful.