I am trying to write a script which validates the Outage start date and Outage end date be within Pl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2023 12:38 PM
I am trying to write a script include which validates the Outage start date and Outage end date be within Planned Start date and Planned end dates. Please some one help me out with this as its a little bit confusing to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2023 12:48 PM
Hi ,
Could you please update it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2023 01:08 PM
Script include named "checkOutageDates":
var checkOutageDates = Class.create();
checkOutageDates.prototype = {
initialize: function() {
},
checkDates: function(outage_start_date, outage_end_date, planned_start_date, planned_end_date) {
var withinPlannedDates = false;
if ((outage_start_date >= planned_start_date) && (outage_start_date < planned_end_date) && (outage_end_date > planned_start_date) && (outage_end_date <= planned_end_date)) {
withinPlannedDates = true;
}
return withinPlannedDates;
},
type: 'checkOutageDates'
};
Test:
var plannedStart = new GlideDateTime('2023-09-20 00:00:00');
var plannedEnd = new GlideDateTime('2023-09-21 00:00:00');
var outageStart = new GlideDateTime('2023-09-20 12:00:00');
var outageEnd = new GlideDateTime('2023-09-20 22:00:00');
var outageWithinPlanned = new checkOutageDates();
var result = outageWithinPlanned.checkDates(outageStart, outageEnd, plannedStart, plannedEnd);
gs.info(result);
result in scripts background:
*** Script: true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2023 01:39 PM
@Jagan9 ,
Can you please review?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2023 09:28 PM