Script to fetch current active on-call roster and associated on-call members based on the assignment group passed as a parameter.

Aman11
Giga Contributor

Hi Team,

Please help me to write a script that will return a list of the currently active on-call roster and associated on-call members based on the assignment group passed as a parameter.

Thanks in advance

1 ACCEPTED SOLUTION

Aman11
Giga Contributor
by using onCallRotation api I am able to achive the requirnment.
var groupSysId = '096fb59173062300e7af6238edf6a783';
var currentTime = new GlideDateTime();
var onCallRotation = new OnCallRotation();
var escalatees = onCallRotation. whoIsOnCall(groupSysId, "", "", currentTime);
gs.log(JSON.stringify(escalatees));

View solution in original post

5 REPLIES 5

RaghavSh
Kilo Patron

This will give you all associated schedules with a group and its primary secondary members.

You can add more queries as per your need:

Try this in background script:

oncall('287ebd7da9fe198100f92cc8d1d2154e'); //sys_id if group

function oncall(assignment)
{

var gr = new GlideRecord('cmn_rota');
gr.addQuery('group',assignment);
gr.query();
while(gr.next())
{
//gs.print(gr.sys_id);
var gr1 = new GlideRecord('cmn_rota_member');
gr1.addQuery('roster.rota',gr.sys_id);
gr1.query();
while(gr1.next()){

gs.print("group name:"+ " "+gr.group.name+" "+ "Member:"+" "+gr1.member.name);


}
}


Raghav
MVP 2023

Aman11
Giga Contributor

I want the current shift group members only. So which query parameter I have to use for it?

What is the exact requirement? current shift means, current time?

 

You can refer:https://community.servicenow.com/community?id=community_blog&sys_id=347c22e1dbd0dbc01dcaf3231f96199a blog for details of scripts in on call.

 


Raghav
MVP 2023

Aman11
Giga Contributor
by using onCallRotation api I am able to achive the requirnment.
var groupSysId = '096fb59173062300e7af6238edf6a783';
var currentTime = new GlideDateTime();
var onCallRotation = new OnCallRotation();
var escalatees = onCallRotation. whoIsOnCall(groupSysId, "", "", currentTime);
gs.log(JSON.stringify(escalatees));