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

Inactive_Us2019
Giga Expert

Hey milan,

Try this!!

var gdt = new GlideDateTime(due_date_reminder);

gs.eventQueueScheduled('problem.task.duedate', current, 'parm1', 'parm2' , gdt);

Hope this helps!

If my reply has helped you,Kindly click the Helpful button.

If my reply is the answer you were looking for, Kindly click the Accepted Solution button.

 

 

 

 

Milan13
Giga Expert

Hi Lavanya,

appreciate your hlep, however it just does not work, what happens this time is just nothing, no notification received, it just does not react, before it reacted immediately, but not at given time - 12hrs...please see below code.

Can't just get my head around this 🙂

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

var gdt2 = new GlideDateTime(due_date_reminder);

gs.eventQueueScheduled('problem.task.duedate', current, 'parm1', 'parm2' , gdt2);

})(current, previous);

Hey,

I feel it didnt send notification because it works i.e it sends the notification only 12 hours before due date. please check your due date once again.

Ex:due date - 7/9/2019 5:30PM

Notification will come on 7/9/2019 5:30AM

Wait till that time..I think the above one works. Check again 12 hours before your due date. You will get a notification

Try testing it by giving due date exactly 12 hours from now.

Thanks

If my reply has helped you,Kindly click the Helpful button.

If my reply is the answer you were looking for, Kindly click the Accepted Solution button.

Milan13
Giga Expert

Actuallly thats exactly what I did.

I tested it the same way again and it just does not work (I can see in the log that the variable due_date_reminder is due_date minus 12hrs...).

No idea why this does not work..

Milan