Create a report for RITMs closed on last working day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2025 11:49 PM
Hi All,
I need to create a report which should reflect all the RITM details ( list view ) 'closed' on the last working day.
Ex. If 'Friday' is the last working day then the report should show all those RITMs
It'll be great if someone could help me out
Thanks and Regards,
Saurabh Chatterjee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 12:14 AM
Are you talking about using Schedule?
If Friday is a holiday then Thursday will be the last working day when Monday starts?
If this is your requirement then I don't think any direct way to handle this is present.
You will have to use custom script
Please explain your business requirement
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 01:57 AM
Hi @Ankur Bawiskar ,
Yes that's correct. That is what is required.
Thanks and Regards,
Saurabh Chatterjee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 02:20 AM
then you will require a custom script include and invoke it from report filter condition.
you will have to get last working day before today's date and once you get that date add query on your table i.e. ticket closed on that day
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 10:51 PM
Hi @Ankur ,
Below is my final logic which I have implemented and it is working fine when I am testing it from 'Scripts-Background' but somehow the Report Filter is unable to fetch the data and hence no results are coming across ( seems the filter is unable to call the script include ) -
Client Callable script -
var getLastWorkingDay = Class.create();
getLastWorkingDay.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getlastWorkingDay: function() {
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek(); // Returns 1 (Sunday) to 7 (Saturday)
var lastWorkingDay = new GlideDateTime(today);
// If today is Monday, subtract 3 days (i.e., Friday)
if (dayOfWeek == 1) {
lastWorkingDay.addDaysUTC(-3);
}
// If today is Sunday, subtract 2 days (i.e., Friday)
else if (dayOfWeek == 7) {
lastWorkingDay.addDaysUTC(-2);
}
// For any other weekday (Tuesday to Saturday), subtract 1 day
else {
lastWorkingDay.addDaysUTC(-1);
}
var date1 = '2025-01-13';
//var sysId = gs.getProperty('mdm.china.catItem');
var arr = [];
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('cat_item', 'b29ac221975bd5d0e32a3e771153afd6');
gr1.query();
while (gr1.next()) {
var gdt2 = new GlideDateTime(gr1.closed_at);
var date2 = gdt2.getDate();
if (date2 == date1) {
arr.push(gr1.getUniqueValue().toString());
}
}
return arr;
},
type: 'getLastWorkingDay'
});
Can you please help let me know where is it going wrong?
Regards,
Saurabh