gs.eventQueueScheduled not working as expected even if supplied with correct arguments

Milan13
Giga Expert

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);

 

1 ACCEPTED SOLUTION

Milan13
Giga Expert

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);

View solution in original post

15 REPLIES 15

Milan13
Giga Expert

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);