- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:11 PM
Hi Experts
I want to print the incidents caller's managers manages names in the background script.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:44 PM - edited 06-13-2024 09:46 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:20 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:42 PM
Hello @dhineshkumar 、can you explain more about the details? Like do you want all incident records or are there any filter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:44 PM - edited 06-13-2024 09:46 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday