How to capture the value of caller's department

Alon Grod
Tera Expert

Hi,

 I have this script include and im trying to get the callers's department but i see the system logs that im not getting anything. I tried to type inc.caller_id.department but it didnt work as well. How can I capture the reference field department from the caller id on incident table?

 

var OperUtil = Class.create();
OperUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {

isService: function() {

var inc = new GlideRecord("incident");
inc.addQuery('active=true');
inc.query();
while (inc.next()) {
var gdt = new GlideDateTime(inc.sys_created_on);
var date = gdt.getDate();

gs.log('inc dept: '+ inc.caller_id.department.getDisplayValue());

var oper = new GlideRecord('u_operational_activity');
oper.addEncodedQuery('u_departments=' + inc.caller_id.department + '^u_from_date<=' + date + '^u_to_date>=' + date);
oper.query();
return oper.hasNext();

}
},

type: 'OperUtil'
});

 

Screen Shot 2023-01-16 at 13.48.11.png

6 REPLIES 6

@Gunjan Kiratkar I have the field Operational impact on the incident table. I need to make this field mandatory if these conditions are met:

1) the department of the caller that created the incident is equal to the department on u_opertioanl_activity table.

AND

2) on the u_operational_activity table we have two fields: From_Date and To_Date. The sys_created_on field from the incident table needs to be between these dates. 
From Date <= sys_created_on =< To_Date

Hi @Alon Grod ,

Please close this thread by marking appropriate response as correct, as you might get the log as expected and Open new thread for above issue. 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy