Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to get department Name from caller field on incident Form

home
Kilo Contributor

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.

20 REPLIES 20

function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if (isLoading || newValue === '') {


return;


}


var caller = g_form.getValue('caller_id');

var gr= new GlideRecord('sys_user');
gr.addQuery('sys_id',caller);
gr.query();
if(gr.next()){

    var gar1=new GlideRecord('cmn_department');
    gar1.addQuery('sys_id',gr.department);

    gar1.query();
    if(gar1.next()){
var dept_name = gar1.name;
g_form.addInfoMessage('Department :' +dept_name);

    }

    }

    
}