Auto populate fields based on the values from another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 12:03 PM
Hi guys,
Am trying to auto populate a catalog items fields based on the selection of a reference field.
In my form a have a reference field, based on the selection of the user, its going to another table and search for the selected used.
We have our table and search for the user. Once the user is found into a record, we need to get the information of the fields (example Location) and populate the fields into the form
select a user for "agreement user"
based on the selection, go to the table to search the user. find the user and get the value of the location, and send the information to the catalog item
i have this client script, that sends me "undefined" values.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var id = g_form.getReference('employee', getValue);
}
var user = new GlideRecord('u_usd_agreement_telecommute');
user.addQuery('number',g_form.getValue('number'));
user.addQuery('employee_lab_location',g_form.getValue('employee_lab_location'));
user.addQuery('u_agreement_start_date',g_form.getValue('u_agreement_start_date'));
user.addQuery('u_agreement_end_date',g_form.getValue('u_agreement_end_date'));
user.query();
if (user.next() ) {
g_form.setValue('number', user.number);
g_form.setValue('employee_lab_location', user.employee_lab_location);
g_form.setValue('agreement_start_date', user.agreement_start_date);
g_form.setValue('agreement_end_date', user.agreement_end_date);
}
Can someone advice me about this??
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 12:12 PM
It's not a good practice to create a GlideRecord in client script, you can find this post helpful on how to get the value from server and then populate on client (Browser). Please use the client script + script include (GlidaAjax)
using GlideAjax to retrieve multiple values off a user record