RITM Issued and Approved date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:46 PM
Hi team,
I have a requirement to extract the timings of RITM created and RITM approved excluding after business hours, National holidays and weekends. Please help me to achieve how to extract the data.
Thanks & Regards,
Nageshwari P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 08:31 PM - edited 02-20-2025 08:31 PM
Hello @Nageshwari P ,
Hello this is achievable by creating a schedule in the cmn_schedule table specific to the dates you mentioned.
Can also navigate through (System Scheduler > Schedules > Schedules).
You can then create a script whether it is business rules/scheduled job etc., to load that schedule and create a logic depending on your needs to extract those RITM.
I'm quite confused on your inquiry though, when you mean "extract the timings" do you meant the dates and time of those record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 09:33 PM
you will get to know the RITM created time, you can get the approval time from sysapproval_approver record
Then find the difference using your schedule (the schedule should exclude holidays, weekends etc
Recently I shared solution for something similar, check that
calculate Duration and Business Duration in scoped application
also check these links
subtract time from schedule to update task due date
Calculate Date By Adding or Subtracting Time With A Schedule
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
02-23-2025 04:12 AM
Hope you are doing good.
Did my reply answer your question?
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
03-25-2025 10:48 AM
Hi,
I have written the below script in scheduled jobs to export the the list of ritm created and approved data. Can you help me to write the script for the above mentioned conditions.
Script:
var grApprover = new GlideRecord('sysapproval_approver');
grApprover.addQuery('state', 'approved');
grApprover.query();
// if (!grApprover.hasNext()) {
// gs.log("No approved approval records found.");
// return;
// }
// CSV Header
var csvContent = "Approval Number,Approver,Approval State,Approval Date,Sysapproval\n";
while (grApprover.next()) {
csvContent += grApprover.getValue('sys_id') + "," +
grApprover.getDisplayValue('approver') + "," +
grApprover.getValue('state') + "," +
grApprover.getValue('sys_created_on') + "," +
grApprover.getDisplayValue('sysapproval') + "\n";
}
// Save as an attachment
var fileName = "Approved_Approvals_" + gs.nowDateTime() + ".csv";
var tableName = new GlideRecord("sys_attachment");
tableName.initialize();// Attach to sys_attachment
var recordSysId = gs.generateGUID(); // Generates a unique record ID
var attachment = new GlideSysAttachment();
attachment.write(tableName,fileName, "text/csv", csvContent);
gs.log("Exported Approved Approvals and saved as an attachment: " + fileName);
Thanks & regards,
Nageshwari P.