How to get department Name from caller field on incident Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 03:55 AM
Hi Team,
So a query is, how to get department name of user on incident form from caller reference field on a text field in incident form(or alert will also do)?
As Caller is a reference field & department inside it is also a reference field, so i am finding a difficulty in getting a name of department on form through client script with glideRecord.
a sample script will be very heplful.
Thanks.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 09:56 PM
Yes, I want department of the User.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:51 AM
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
function doAlert(caller) { //reference is passed into callback as first arguments
alert(caller.department);
g_form.setValue('description',caller.department); // just for the sake of testing i had set it on description field.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:53 AM
The getReference() function falls short for your use case since you need to "dot-walk" twice to get the name of the department = 1. user, 2 department. Please see my getReferenceAdvanced solution as this will solve your issue easily. Details can be found below and the code is on Share.
getReferenceAdvanced, g_form.getReference and GlideAjax Alternatives
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:34 PM
You can use dot walking for the same.
caller_id.deparment.name
it will get the exact value
thanks
trinadh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:38 PM
Hi,
Alert is coming as 'undefined'.
Thanks.