How can I script the CAB agenda refresh?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 01:00 PM
I have tried flow designer, scheduled scripts, and business rules.
My script looks good, but I am still unable to successfully refresh the CAB agenda from anything other than clicking the UI action from the meeting.
//FROM BUSINESS RULE
// refresh agenda items for next available CAB meeting
var grMeeting = new GlideRecord('cab_meeting');
var encQuery = 'active=true^start>javascript:gs.endOfToday()^startRELATIVELT@dayofweek@ahead@8';
grMeeting.addEncodedQuery(encQuery);
grMeeting.query();
if (grMeeting.next()) {
var cabMeeting = new sn_change_cab.CABMeeting(grMeeting);
cabMeeting.refreshChangeAgendaItems();
}
//FROM Scheduled Script
// refresh agenda items for next available CAB meeting
var grChange = new GlideRecord('change_request');
grChange.addQuery('type','0'); //Normal
grChange.addOrCondition('type','1'); //Emergency
grChange.addQuery('state','-3'); //Authorize
grChange.addQuery('approval','requested');
grChange.query();
while(grChange.next()){
var grMeeting = new GlideRecord('cab_meeting');
var encQuery = 'active=true^start>javascript:gs.endOfToday()^startRELATIVELT@dayofweek@ahead@8';
grMeeting.addEncodedQuery(encQuery);
grMeeting.query();
if (grMeeting.next()) {
var cabMeeting = new sn_change_cab.CABMeeting(grMeeting);
cabMeeting.refreshChangeAgendaItems();
}
}
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 06:19 PM
Hi, unfortunately your post\scripts doesn't make your indented process clear and your scheduled job appears to be looping through change request that meet your cab requirements and repeatedly calling refreshChangeAgendaItems().
I think that you should only need to call refreshChangeAgendaItems() once and that the change_requests updated into your agenda would be dependent on your CAB definition.
I (semi) automated a cab process a few years ago and posted details for the scheduled job here
Simple automation of CAB meeting creation, agenda ... - ServiceNow Community
Hopefully this is still current and will help you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 10:22 PM
Hi @sharepointau ,
I trust you are doing great.
To refresh the CAB agenda items for the next available meeting, you can use a combination of a scheduled script and a business rule. Here's an updated code snippet that combines the functionality:
// FROM SCHEDULED SCRIPT
// Refresh agenda items for the next available CAB meeting
var grChange = new GlideRecord('change_request');
grChange.addQuery('type', '0'); // Normal
grChange.addOrCondition('type', '1'); // Emergency
grChange.addQuery('state', '-3'); // Authorize
grChange.addQuery('approval', 'requested');
grChange.query();
while (grChange.next()) {
var grMeeting = new GlideRecord('cab_meeting');
var encQuery = 'active=true^start>javascript:gs.endOfToday()^startRELATIVELT@dayofweek@ahead@8';
grMeeting.addEncodedQuery(encQuery);
grMeeting.query();
if (grMeeting.next()) {
var cabMeeting = new sn_change_cab.CABMeeting(grMeeting);
cabMeeting.refreshChangeAgendaItems();
}
}
The scheduled script iterates over the change requests that meet the specified criteria (normal or emergency changes in authorized state with requested approval). For each matching change request, it searches for the next available CAB meeting that satisfies the query conditions (active and starting within the next 8 days, after the end of the current day). If a meeting is found, it instantiates the CABMeeting class and calls the refreshChangeAgendaItems() method to refresh the agenda items.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi