- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 04:40 AM - edited 10-09-2024 05:19 AM
Hi team,
I have requirement to send notification one day before and one day after a variable date field in catalog item. I used scheduled job,event and notification for that...but when its running daily its sending notification everyday and it seems not working....like if i keep date as 9oct in date field in catalog form so one noti should be send on 8 and one on 10th but it seems not working can anyone please help me attaching schedule job script here:- @Sandeep Rajput @Dr Atul G- LNG
Before:-
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 02:08 AM
Hello Priyanka,
Can you try this below,
I have executed this in background script, also I see that this is a date/time field so getDisplayValue will not work properly, just getDate should do that job.
var catalogItemSysId = '6830ece6937056109458f44e1dba10ee';
var variableDateField = 'expected_return_date';
var grBefore = new GlideRecord('sc_req_item');
grBefore.addQuery('cat_item', catalogItemSysId);
grBefore.query();
while (grBefore.next()) {
var dt = grBefore.variables[variableDateField];
if (dt) {
var expectedDate = new GlideDateTime(dt);
gs.info('expectedDate' +expectedDate);
var today =new GlideDateTime();
var oneDayBefore = new GlideDateTime(dt);
oneDayBefore.addDays(-1);
gs.info('today' +today);
if (today.getDate().getNumericValue() == oneDayBefore.getDate().getNumericValue()) {
{
gs.eventQueue('loaner.request.one.day.before', grBefore, grBefore.requested_for, '');
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2024 11:25 PM
For logs its printing all values because its checking all dates....but ill attach my scenario here.....today is oct 14 I submitted 2 request in one i kept expected return date 15 and in one 16...now when I runned the back script for both RITM before email got triggered I have attached the email also for you....for request having 16 date that email should have been triggered tomorrow not today that's the issue.... @Omkar Mone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 02:08 AM
Hello Priyanka,
Can you try this below,
I have executed this in background script, also I see that this is a date/time field so getDisplayValue will not work properly, just getDate should do that job.
var catalogItemSysId = '6830ece6937056109458f44e1dba10ee';
var variableDateField = 'expected_return_date';
var grBefore = new GlideRecord('sc_req_item');
grBefore.addQuery('cat_item', catalogItemSysId);
grBefore.query();
while (grBefore.next()) {
var dt = grBefore.variables[variableDateField];
if (dt) {
var expectedDate = new GlideDateTime(dt);
gs.info('expectedDate' +expectedDate);
var today =new GlideDateTime();
var oneDayBefore = new GlideDateTime(dt);
oneDayBefore.addDays(-1);
gs.info('today' +today);
if (today.getDate().getNumericValue() == oneDayBefore.getDate().getNumericValue()) {
{
gs.eventQueue('loaner.request.one.day.before', grBefore, grBefore.requested_for, '');
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 03:33 AM
Tysm @Omkar Mone for the detailed help on this by considering this problem as yours only !! Really tysm for all the efforts! Just one last ques i should run this Schedule job daily at 12 am right?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 04:19 AM
Hello Priyanka,
It depends, does your customer want email to be received at midnight? If yes, you can, else I would suggest having it just before the day starts, around 830am, whenever you run, it's fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 04:23 AM
Ok tysm @Omkar Mone great idea