Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 06:36 AM
I got the result by below script.
//Client callable script include
var BusinessDays = Class.create();
BusinessDays.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Bdays: function() {
var temp = new ExcludeHolidays().holidays(); // getting last business day (considering 30 business days) refer script below.
var array = [];
var c = 0;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_created_on<' + temp);//assignment group Parent is AAFR_XX_CG_ComputaCenter
gr.query();
while (gr.next()) {
array.push(gr.number.toString());
}
return array;
},
type: 'BusinessDays'
});
============//getting last business day from today(30 days ago)
var ExcludeHolidays = Class.create();
ExcludeHolidays.prototype = Object.extendsObject(AbstractAjaxProcessor, {
holidays: function() {
var count = 0;
var tday = new GlideDateTime();
var temp = tday; //temporary variable
while (count < 30) {
if (temp.getDayOfWeekUTC() != 6 && temp.getDayOfWeekUTC() != 7) {
count = count + 1;
} //excluding weekends
var schedule = "US Holidays";
var sch = new GlideRecord("cmn_schedule");
sch.addQuery("name", schedule);
sch.query();
if (sch.isInSchedule(temp)) {
count = count - 1; //reducing count since last count was including holidays
}
temp.addDaysUTC(-1); // reducing day by 1
}
return temp; // returning business day 30 days ago
},
//in the filter you need to add
Number is one of javascript: new BusinessDays().Bdays();