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 10:48 AM
Hi Rahul,
you can use call back function by using getReference().
var caller = g_form.getReference('caller_id', showcallerTitle);
function showcallerTitle(caller) {
alert(caller.department); //if you want to set then use g_form.setValue() function.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:08 PM
My Department Field is also a reference field inside caller field.
So I am getting sys_id instead of department Name.
and my caller field look alike this :
so department name is itself a ref. field.
So I just want a sales should get pop up in caller department.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:20 PM
Share your script here
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 10:33 PM
Hi Rajesh,
I am pasting my scripts below.
as i have tried both scripts but they are giving me same output i.e. SYS_ID.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//Script 1:
var caller = g_form.getValue('caller_id');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', caller);
gr.query();
if(gr.next())
{
alert(gr.department);
}
// Script 2:
//var caller = g_form.getReference('caller_id', getDepartmentName);
//function getDepartmentName(caller) {
//alert(caller.department);
//}
Thanks.