
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 09:39 AM
Hi,
I am trying to write a client script on change of "contact" record, I want to auto populate the fields like manager's name, email address etc. Manager field is a reference to sys_user table.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var contact = g_form.getReference('contact', callBack);
}
function callBack(contact)
{
g_form.setValue('u_employee_last_name', contact.last_name);
g_form.setValue('u_employee_first_name', contact.first_name);
g_form.setValue('u_work_email_address', contact.email);
g_form.setValue('u_manager_name', contact.manager);
g_form.setValue('u_manager_first_name', contact.manager.first_name);
g_form.setValue('u_manager_last_name', contact.manager.last_name);
}
Here is what I have so far and the results are turned out to be "undefined"
Please help. Thank you
Solved! Go to Solution.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:33 PM
Thanks for the detailed update.
Can you make your Manager (custom field) to be of type Reference instead of String.
If so, in the above script you need to comment last 2 lines where you set first name & last name.
Then get another onChage() client script written that takes the manager value & gets the first name & last name with the code similar to one you used above to get in Contact's first name & last name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 09:46 AM
Hi Angel,
You are using getReference() which acts as dot-walk for user table. For Manager's First & Last name it is double dot-walk. So it will not work in client script as above.
Better to change the Manager field above to be Reference rather than string & remove the First & Last Name to be set from the script above.
Once done you can have another Client script that runs onChange() of manger field & since it would be a reference field you can follow the approach that you have followed above for populating First & Last name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 11:02 AM
Hi Jaspal,
Manager field is a Reference field in the contact form but I am trying to get managers name, email in the case form so that I could use save them for each case record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 11:08 AM
Hi Angel,
If I understand correctly Contact is a reference to User table where you select a User & which user is selected in the Contact field you need to check for corresponding manager.
Correct me if this is not the case.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 11:26 AM
Hi Jaspal,
To clarify, the contact table (customer_contact) is an extended table from user (sys_user).
I have a case form (sn_customerservice_case) which is an extended table from TasK.
In sn_customerservice_case there is a field named "contact" which is a reference field to the customer_contact.
Manager is a custom field I created in sn_customerservice_case table to get the contact's manager name.
I am trying to get user/employee details and manager details in the Case form and store the data in the case record.
Hope this help