- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 10:39 PM
Hi,
Can anyone help please.
I have a reference field(sys_user) in incident . When a user is selected automatically the other field (u_user_manager) should populate the manager of the user.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:36 PM
You need to have a Client Script as:
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue == '') {
- return;
- }
- var user = g_form.getReference('<<fieldname>>');
- g_form.setValue('u_user_manager', user.manager);
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 10:48 PM
This will be the onChange script on your user field:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
g_form.setValue('u_user_manager', newValue.manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:11 PM
Hi Edwin,
Thanks for the script. So if I understood correctly: No need to define sys_user table via gliderecord?
client script
Type: on Change
Table: incident
Field: User Name //this is custom field reference to sys_user table
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue == '') {
- return;
- }
- g_form.setValue('u_user_manager', newValue.manager);
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 11:50 PM
Hi snowuser11,
I don't think the above will work since you are using a Client Script. Client Scripts do not usually allow you to dot walk in that way unless some change has been made in that regard. You could accomplish this without client scripts as long as you don't need to use the custom field u_user_manager. If this is an option, do the following:
1. Configure/Personalize the Form Layout
2. Select the user reference field but don't add it to the form
3. Depending on your instance version, click the green plus sign or the icon highlighted in red in the image below. This will reveal the fields for the User table in the left hand box
4. Select Manager and add it to your form layout. Now, when you change the User field, the Manager field will update automatically, no client script required
If this is not an option and you must use the u_user_manager field, then you will need to use g_form.getReference in your client script. You can use the Incident client script (BP) Set Location to User as a reference. I have included a simplified/modified version of this script to assist:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
// If User is empty, clear
if (newValue == '') {
g_form.setValue('u_user_manager', '');
return;
}
// getReference will run an ajax call to the server to get the data. When the data is returned, setManager is executed as the callback function
var caller = g_form.getReference('caller_id', setManager);
}
// caller contains the record fields retrieved by getReference when the callback is executed
function setManager(caller) {
if (caller)
g_form.setValue('u_user_manager', caller.manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 06:38 AM
Could you decipher the dropdown items on the list shown in the screen capture I have included below? I would like to create a dropdown list that will show all users in a department when a custom organization field is selected above in the form. I can't seem to be able to locate my custom field to complete the reference qual condition.