
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2018 01:19 PM
Issue -
Due to the On-Call Calendar Schedule being setup for 8 to 4:30 with someone scheduled to assign a person to an Incident
The only option for the On-Call Rota is when an incident is create outside a schedule with no Assigned To is to update the Assignment Group and leave the Assigned to empty.
The On-Call Rota will not rerun again the next business day to find those incidents that came in after hours
So we are looking to create a Scheduled Job to run at 8:00 am to find any Active Incidents with the Assigned to is empty then update the Assigned to with the Current On-Call Person for that Assignment Group
Would have to Query the Incident and the cmn_rota Tables
From the Incident table would have to guery any active is true and assigned_to is empty incidents - Would think we want to return Number and Assignment Group
From the Rota cmn_rota table would need to query the matching assignment group then return the current on-call rota member
Would then need to have the current on-call rota member placed in the incident assigned to field
This in turn would update Incidents where the Assigned to was empty with the current On-Call person for that Assignment Group on the next business day.
And to add even more twist - Can it be scheduled to only occur Monday thru Friday would want to exclude weekends
Is this something that can be done?
Mark
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 02:24 PM
Anil,
You are awesome!
Thank You again for your Help.
Final Script that work great.
assinOnCall() ;
function assinOnCall() {
var query = 'assignment_groupISNOTEMPTY^assigned_toISEMPTY';
var grInc = new GlideRecord('incident');
grInc.addEncodedQuery(query);
grInc.query();
while (grInc.next()) {
var group = grInc.assignment_group.sys_id + '';
var assigned_to = getOnCall(group) + '';
if(assigned_to != '') {
grInc.assigned_to = assigned_to;
grInc.update();
}
}
}
function getOnCall(groupId) {
var returnAssignee = '';
var rota = new OnCallRotation() ;
var hasRota = rota.who(groupId) + '';
if(hasRota == 'true') {
returnAssignee = rota.getPrimaryUser();
}
return returnAssignee;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 10:57 AM
Anil,
it's not pulling the getPrimaryUser - Records are not updating
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 06:11 AM
Dear Mark,
I ran the script on my personal dev instance and I see that it is returning the assignee as you can see from below screenshot. Can you run this piece of code as a background script and check if it returns anything.
var groupId = 'sysid of the group';
var rota = new OnCallRotation() ;
gs.print(rota.getPrimaryUser(groupId));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 07:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 07:50 AM
Do you see all these script includes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 08:14 AM
Yes - I have those
The Version I am using in my Personnel Instance is Kingston Patch1
I have created New Calendars with Groups and Triggers those are working to assign the primary User of the Group to a Incident.
I reran the script using one of the OOB Groups still received null
var groupId = '287ebd7da9fe198100f92cc8d1d2154e'; - This is the Network Group sysID
var rota = new OnCallRotation() ;
gs.print(rota.getPrimaryUser(groupId));