Tony Chatfield1
Kilo Patron

As the assistant to the junior coffee boy (in a team of 1) I am frequently asked to undertake a number of taxing actions on behalf of the business….After nearly forgetting (yet again) to update a CAB agenda and send invites, I decided it was time to 'embrace change'.
Not very difficult as our CAB process is not complex and the core functions required are already clearly identified in existing UI Actions. All it needs is a scheduled job and a few small tweaks to tie it all together.

Notes

  • This makes no allowance for ‘extendedTimings’, but splicing in the code from the UI actions and a sys_event trigger with a matching notification should be simple.
  • Invites will be sent to Cab members even if there are no agenda items (not a situation we encounter), but if your organisation has weeks where you have no changes to be reviewed you may want to encapsulate the invite function in to a simple check of ‘cab_agenda_item’ .

I also assume the CAB runs only once a week, but defining alternate days to increment the ‘repeat_until’ date would only be a matter of a simple condition based around getDayofWeek(); Although I suspect any organisation running multiple weekly CAB meetings probably has dedicated change management and a clear process to ensure meetings, agenda and attendees are all managed correctly.

var now = new GlideDateTime();
var myCabDefinition = 'your_cab_definition_sys_id';

//First we create the new cab meeting by getting our cab definition record.
//The definitions schedule will decide if a meeting should be created, make sure your repeat until date is a day or 2 after your first cab date
var myCabParent = new GlideRecord('cab_definition');
myCabParent.get(myCabDefinition);

new sn_change_cab.CABDefinition(myCabParent).refreshMeetings();

//Now we find the meeting that has just been created
var myNewMeeting = new GlideRecord('cab_meeting');
myNewMeeting.addActiveQuery();
myNewMeeting.addQuery('cab_definition', myCabDefinition);
myNewMeeting.orderByDesc('sys_created_on');
myNewMeeting.setLimit(1);
myNewMeeting.query();

//Then populate the meeting agenda and send the invites
if (myNewMeeting.next()) {
    var cabMeeting = new sn_change_cab.CABMeeting(myNewMeeting);
    cabMeeting.refreshChangeAgendaItems();
    cabMeeting.createCABAttendeeNotifyEvents(now);
}

//Finally we increment the definition schedule 'repeat until' by 7 days
//We do this weekly so that if the CAB definition is changed there is no remedial action necessary.
var mySchedule = new GlideRecord('cmn_schedule_span');
mySchedule.get('schedule', myCabParent.sys_id);
myScheduleString = mySchedule.repeat_until;

var myDate = new GlideDateTime(myScheduleString.substring(0, 4) + '-' + myScheduleString.substring(4, 6) + '-' + myScheduleString.substring(6, 8));

myDate.addDaysLocalTime(7);
mySchedule.repeat_until = myDate.toString().substring(0, 10);
mySchedule.update();
Version history
Last update:
‎07-03-2020 12:32 AM
Updated by: