- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 03:35 AM
Hello,
I need to trigger an event using business rule on problem_task table once due_date changes, need to subtract 12hrs from due_date and at that time notification needs to be triggered using an event.
The problem is that the event is triggered and notification is sent , but immediately, not 12hrs prior to the due_date time.
Please see below code, when checking log the time is always due_date - 12hrs, the date arithmetics just works but it seems the gs.eventQueueScheduled method does not recognize it for some rreason, I also checked the date format and it's just fine.
Can anyone please help?
Thanks a lot, Milan
(function executeRule(current, previous /*null when async*/) {
var gdt = new GlideDateTime();
gdt.setValue(current.due_date.getDisplayValue());
gdt.addSeconds(-43200);
var due_date_reminder = gdt.getValue();
gs.log('MILAN STORY 75: ' + due_date_reminder);
gs.eventQueueScheduled('problem.task.duedate', current, 'parm1', 'parm2' , due_date_reminder);
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2019 03:24 AM
So, finally , this works...
(function executeRule(current, previous /*null when async*/) {
var dueDate=current.due_date;
var gdt = new GlideDateTime(dueDate);
gdt.subtract(43200000);
gs.eventQueueScheduled('problem.task.duedate', current, 'parm1', 'parm2', gdt);
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 05:06 AM
Hi
Can you show, what the output from the "gs.log()" message exactly is?
Furthermore, what is the exact value of the "due_date" field?
Also, can you take a screenshot of the System Event, with the field "Process on". This should hold the date/time, when the Event should be picked up for sending the notification.
If the event was created, is unprocessed and the date is in the future, your requirement will be met.
Just let me know.
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 05:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 05:18 AM
So far so good. Now, let's have a look at the Event Details generated by "gs.eventQueueScheduled()" command. Can you supply a screenshot of that, please?
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 05:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2019 01:55 AM
Hi
Yes, that is the record I am searching for. You can see, that this event has not been processed so far, because the field "Processed" is still empty. Can you please add the field "Process On" in the list.
This value is the date/time, the Event is supposed to be processed EARLIEST!!!
That does not mean, that it will be processed as soon as this date/time has arrived, but the event processor will not touch this event BEFORE.
Here is an example of my List of the Events:
You can see, that the events in my Log are processed.
If your Events are created with a date in the future, then the system already may behave as expected.
Let me know, if that answers your question, and mark my answer as correct or helpful
BR
Dirk