- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 08:10 AM
- 30 Days – 1st notification if the RITM is not closed.
- 15 Days – Daily notification with CC to some users if RITM is not closed.
- 7 Days - Daily notification and CC to move to TO and TO to CC if RITM is not closed.
how to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 09:48 PM
Create a scheduled job and make it to run once a day (everyday) and use below script in the scheduled job,
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('active', true);
ritmGr.addQuery('state', 'NOT IN', 'closed, cancelled');
ritmGr.addQuery('sys_created_on', '<', gs.daysAgoStart(30));
ritmGr.query();
while (ritmGr.next()) {
gs.eventQueue('my_custom_event', ritmGr);
}
This script queries for active RITMs that are not closed or cancelled, and were created more than 30 days ago. For each matching RITM, it triggers a custom event named "my_custom_event" and passes the RITM as the payload.
Create a new "Event Handler" record in ServiceNow with the following settings:
- Name: My Custom Event Handler
- Event: my_custom_event
- Active: true
- Script:
var ritm = event.parm1;
// Send 1st notification if RITM has been open for 30 days
if (ritm.sys_created_on <= gs.daysAgoStart(30)) {
gs.eventQueue('my_1st_notification_event', ritm);
}
// Send daily notifications with CC to some users if RITM has been open for 15 days
if (ritm.sys_created_on <= gs.daysAgoStart(15)) {
gs.eventQueue('my_daily_notification_event', ritm);
}
// Send daily notifications with CC to move to TO and TO to CC if RITM has been open for 7 days
if (ritm.sys_created_on <= gs.daysAgoStart(7)) {
gs.eventQueue('my_7_day_notification_event', ritm);
}
This script handles the "my_custom_event" by checking the RITM's creation date and triggering three additional custom events, depending on how long the RITM has been open.
Create three more "Event Handler" records in ServiceNow, one for each of the custom events triggered by the previous handler. Set the "Script" option of each event handler to perform the desired notification actions (e.g., sending emails, creating tasks, etc.) with the appropriate CC list and content.
Once you have set up these business rules and event handlers, they will run on the schedule you specified and trigger notifications for RITMs that match the specified criteria. You can modify the script and event handler code as needed to customize the notification content and CC lists.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 02:32 PM
Hi,
Can you please elaborate the requirement?
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 05:41 PM
Hi Saurabh,
According to user requirements we configured that if certificate is going to expire at 60days(Left).
RITM will auto generate and assigned to respective group.
To monitor the above RITM, we need to configure below,
- 30 Days (Left) – 1st notification if the RITM is not closed.
- 15 Days(Left) – Daily notification with CC to some users if RITM is not closed.
- 7 Days (Left) - Daily notification and CC to move to TO and TO to CC if RITM is not closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 05:51 PM
Hi Abhilasha,
You can achieve this using the flow designer.
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2023 09:48 PM
Create a scheduled job and make it to run once a day (everyday) and use below script in the scheduled job,
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('active', true);
ritmGr.addQuery('state', 'NOT IN', 'closed, cancelled');
ritmGr.addQuery('sys_created_on', '<', gs.daysAgoStart(30));
ritmGr.query();
while (ritmGr.next()) {
gs.eventQueue('my_custom_event', ritmGr);
}
This script queries for active RITMs that are not closed or cancelled, and were created more than 30 days ago. For each matching RITM, it triggers a custom event named "my_custom_event" and passes the RITM as the payload.
Create a new "Event Handler" record in ServiceNow with the following settings:
- Name: My Custom Event Handler
- Event: my_custom_event
- Active: true
- Script:
var ritm = event.parm1;
// Send 1st notification if RITM has been open for 30 days
if (ritm.sys_created_on <= gs.daysAgoStart(30)) {
gs.eventQueue('my_1st_notification_event', ritm);
}
// Send daily notifications with CC to some users if RITM has been open for 15 days
if (ritm.sys_created_on <= gs.daysAgoStart(15)) {
gs.eventQueue('my_daily_notification_event', ritm);
}
// Send daily notifications with CC to move to TO and TO to CC if RITM has been open for 7 days
if (ritm.sys_created_on <= gs.daysAgoStart(7)) {
gs.eventQueue('my_7_day_notification_event', ritm);
}
This script handles the "my_custom_event" by checking the RITM's creation date and triggering three additional custom events, depending on how long the RITM has been open.
Create three more "Event Handler" records in ServiceNow, one for each of the custom events triggered by the previous handler. Set the "Script" option of each event handler to perform the desired notification actions (e.g., sending emails, creating tasks, etc.) with the appropriate CC list and content.
Once you have set up these business rules and event handlers, they will run on the schedule you specified and trigger notifications for RITMs that match the specified criteria. You can modify the script and event handler code as needed to customize the notification content and CC lists.