Populate variables from sys user table based on 'Requested for'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 08:21 AM
Hi all,
Iam working on a catalog item. The requirement is to autopopulate 6 fields (Fname, Lname, Title, Department, Email,Phone,) based on Requested For field.
In the catalog item variables, I have set the default value for all the 6 variables like below, so when the form loads all these 6 fields are populated. So no issues on that part.
javascript:(gs.getUser().getRecord().getValue("first_name"));
javascript:(gs.getUser().getRecord().getValue("last_name"));
javascript:(gs.getUser().getRecord().getValue("title")); .......etc
If the 'requested_for' value is changed then all these values should be populated based on the user data. I have written an onchange client script but that doesnt seems working. Below is the script. Any guidance would be much appreciated.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = g_form.getReference('requested_for', getUser);
}
function getUser(gr){
g_form.setValue('dccr_forename', gr.first_name);
g_form.setValue('dccr_surname', gr.last_name);
g_form.setValue('dccr_work_email', gr.email);
g_form.setValue('dccr_jobtitle', gr.title);
g_form.setValue('dccr_service_dpt', gr.department);
g_form.setValue('dccr_contact_number', gr.phone);
}
Thanks,
Rini

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 08:31 AM
Hi Rini,
Script seems to be fine. None of field is getting set with above script or there are few but few fields are not set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 09:01 AM
Hi Jaspal,
None of the field is getting updated. It stays with the caller details, and not getting updated with the 'Requested for' User.
Thanks,
Rini

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 09:21 AM
As a suggestion can you try below.
1. Pass default value for requested_for only & not for other variables
2. Create an onLoad() script with code same as above instead of using default values for other variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:45 AM
Hi Jaspal,
I have removed the default value from other variables and created an onLoad script but the fields are still not populating for Requested For fields, Any thoughts?
Thanks,
Rini