issue with request got auto closed before maintainance schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
We noticed that suppression requests in the change CHG00XXXXX has been auto closed prior maintenance window end time
Due to this we've received multiple P2 alerts during our planned outage windows.
We check with Monitoring Devops, and they confirmed its not due to splunk issue and that it is related to the suppression request being auto closed before end time.
When we checked few SR, they all seem to be closed around the same time 25/6/26 2:56 AM
I have attached the suppression request that were auto closed. Kindly check what happened to the requests during that time and why was it closed. How to troubleshoot this issue. I have checked one of the schedule job is run to close the Requested Item when the associated Maintenance schedule expires but it is closing the RITM before maintenance window. Below script is used. apart from this any parameter do i need to check to resolved this issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @vidyajadhav , Try this below script and let me know if it works as per your requirement!
var tmpQuery = "cat_item=338aa285dbe9815051df8a1705961930";
var tmpRITM = new GlideRecord("sc_req_item");
tmpRITM.addActiveQuery();
tmpRITM.addEncodedQuery(tmpQuery);
tmpRITM.query();
while(tmpRITM.next()) {
var tmpNumber = tmpRITM.number;
var tmpMaintSchedule = new GlideRecord('cmn_schedule_maintenance');
tmpMaintSchedule.addQuery('name', 'CONTAINS', tmpNumber);
tmpMaintSchedule.query();
if(tmpMaintSchedule.next()) {
var tmpschedID = tmpMaintSchedule.sys_id;
var tmpschedule = new GlideSchedule(tmpschedID);
// FIX 1: Fetch the schedule's specific timezone
var schedTimezone = tmpschedule.getTimeZone();
var tempdt = new GlideDateTime();
// FIX 2: Set the current time object to look at the schedule's timezone
if (schedTimezone) {
tempdt.setTZ(schedTimezone);
}
if (tmpschedule.isValid()) {
// FIX 3: Robust check. Ensure it is NOT currently in schedule
// AND ensure the end date/time of the window is strictly in the past.
if(!tmpschedule.isInSchedule(tempdt)) {
// Fetch the end date of the schedule schedule span to confirm it's actually over
var isExpired = false;
var span = new GlideRecord('cmn_schedule_span');
span.addQuery('schedule', tmpschedID);
span.query();
if(span.next()) {
var spanEnd = new GlideDateTime(span.end_date_time);
if(tempdt.getNumericValue() > spanEnd.getNumericValue()) {
isExpired = true;
}
}
if(isExpired) {
tmpRITM.state = 3;
tmpRITM.assigned_to = 'a782a191db4e819074d6150505961925';
tmpRITM.autoSysFields(false);
tmpRITM.update();
tmpMaintSchedule.u_active = false;
tmpMaintSchedule.autoSysFields(false);
tmpMaintSchedule.update();
this.deactivateSpanEntries(tmpMaintSchedule.sys_id);
this.deactivateM2mMaintenanceServerEntries(tmpMaintSchedule.sys_id);
}
}
}
}
}
If this response helps you mark it as accepted solution and give it a thumbs up 👍. This help me and community to find answers quickly.
Best Regards,
Saurabh V.