Print the incident caller's managers manages names in the background script.

dhineshkumar
Tera Guru

Hi Experts 

I want to print the incidents caller's managers manages names in the background script.

Thanks in advance.


1 ACCEPTED SOLUTION

Jitendra Diwak1
Kilo Sage

Hi @dhineshkumar,

 

Please find the below code for the manager'manager :

 

var inc = new GlideRecord('incident');
inc.get('57384e19c332021003c8deec05013184');//pass the incident record's SYSID
inc.query();
var incusr = inc.caller_id;
gs.info('user Name ' +incusr.name);
gs.info('Manager Name ' +inc.caller_id.manager.manager);//here you will get manager's manager SYSID

 

 

Please avoid multiple glideRecord. It will downgrade your performance

Please accept my solution if it works for you and thumps up.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

View solution in original post

8 REPLIES 8

Yashsvi
Kilo Sage

Hi @dhineshkumar

Print the incident caller's manager's and manager's manager's names:


var incidentSysId = 'YOUR_INCIDENT_SYS_ID';

var incidentGR = new GlideRecord('incident');
if (incidentGR.get(incidentSysId)) {
var callerGR = new GlideRecord('sys_user');
if (callerGR.get(incidentGR.caller_id)) {
var managerGR = new GlideRecord('sys_user');
if (managerGR.get(callerGR.manager)) {
gs.print('Caller\'s Manager: ' + managerGR.name);
var managerManagerGR = new GlideRecord('sys_user');
if (managerManagerGR.get(managerGR.manager)) {
gs.print('Caller\'s Manager\'s Manager: ' + managerManagerGR.name);
} else {
gs.print('Caller\'s Manager\'s Manager: Not found');
}
} else {
gs.print('Caller\'s Manager: Not found');
}
} else {
gs.print('Caller: Not found');
} else {
gs.print('Incident: Not found');
}

 

Replace `'YOUR_INCIDENT_SYS_ID'` with the actual sys_id of the incident. This script should be run in the Scripts - Background module of. 

Thank you, please make helpful if you accept the solution.

Zack Hilacan1
Mega Sage

Hello @dhineshkumar 、can you explain more about the details? Like do you want all incident records or are there any filter?

Jitendra Diwak1
Kilo Sage

Hi @dhineshkumar,

 

Please find the below code for the manager'manager :

 

var inc = new GlideRecord('incident');
inc.get('57384e19c332021003c8deec05013184');//pass the incident record's SYSID
inc.query();
var incusr = inc.caller_id;
gs.info('user Name ' +incusr.name);
gs.info('Manager Name ' +inc.caller_id.manager.manager);//here you will get manager's manager SYSID

 

 

Please avoid multiple glideRecord. It will downgrade your performance

Please accept my solution if it works for you and thumps up.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

hey @Jitendra Diwak1 

 

This code works well but I was getting sys_id of the manager not his name