Want to send notification based on date field in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-27-2024 01:39 AM
We have q request to send notification to requestedfor based on date. A date field is present in catalog item based on what is selected date on that field before 1 day and after 1 day we need to send a notification. For ex:-if i select 25th date so on 24 and 26 need to send a email notification. Can anybody help me on this requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-27-2024 04:58 AM - edited ā09-27-2024 05:03 AM
Hello @Burhan2,
Please find the below link and let me know whether it is helpful or not.
https://www.servicenow.com/community/developer-forum/creating-schedule-job-to-send-notification/m-p/...
you can follow the solution provided in the above link. but please create two schedule jobs, two events & two notifications to trigger.
1) First schedule job is for triggering notification 1 day before. create event and email notification for first schedule job.
2) second schedule job is for triggering notification 1 day after. create event and email notification for second schedule job.
Ensure that both schedule jobs are set to run daily so they can check the dates and send notifications accordingly.
You can find the sample schedule job scripts and modify as per your requirement.
var gr = new GlideRecord('sc_req_item'); // Change this to your table
gr.addQuery('u_selected_date', '=', gs.daysAgoStart(-1)); // 1 day before
gr.query();
while (gr.next()) {
gs.eventQueue('your_event_before', gr, gr.requested_for, ''); // Event to trigger email
}
var gr = new GlideRecord('sc_req_item'); // Change this to your table
gr.addQuery('u_selected_date', '=', gs.daysAgoStart(1)); // 1 day after
gr.query();
while (gr.next()) {
gs.eventQueue('your_event_after', gr, gr.requested_for, ''); // Event to trigger email
}
Thanks
SP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2024 03:03 AM
Hey @SP22 when i am checking the emails i kept the schedule job to run daily....but both emails are getting triggered on the same day...as per my condition one email should be triggered after the expected date can you let me know why its happening??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2024 04:46 AM
@KarthikB9365919 did you used this script ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-09-2024 01:03 AM
@Ankur Bawiskar can you help me on this...this is not working the emails are triggering everyday and condition is not working