How to trigger notification using gs.eventQueueScheduled based on a date/time field from incident form using business rule

Milan13
Giga Expert

Hello,

I have a custom date/time field placed in the incident form - once this is changed a business rule is triggered and notification should be sent at the time specified in given date/time field.

In my Business Rule I decided to use this method:

gs.eventQueueScheduled('on.hold.reminder', current, 'parm1', 'parm2' , gs.getValue('u_on_hold_reminder'));

u_on_hold_reminder - the date/time field mentioned

I made a notification which is sent once an event 'on.hold.reminder' is triggered as per the method above.

The problem is that it is triggered everytime the date/time field is changed and it does not reflect the date/time value for schedulling the event, not sure if I supply these parameters correctly.

Can anyone please advise?

Many thanks.

Milan

 

 

 

1 ACCEPTED SOLUTION

VIVEK ANAND
Mega Guru

gs.eventQueueScheduled does not return a value. so your if condition wont pass.

remove the If condition and place the code it should work fine.

Example:

gs.eventQueueScheduled('on.hold.reminder', current, 'parm1', 'parm2', current.u_on_hold_reminder);

current.state = 'Assigned';
current.assigned_to = "";
current.update();

Please refer to docs for more details on API: https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_SGSYS-eventQSched_S_O_S_S_O

 

Thanks,
Vivek Anand

Please Note: If my response helps you to fix this issue, please mark it as correct!

View solution in original post

11 REPLIES 11

VIVEK ANAND
Mega Guru

HI Milan,

 

When i look at your code i issue is with the parameters you pass. you need to pass 'current.u_on_hold_reminder.getDisplayValue()' instead of gs.getValue('u_on_hold_reminder')

 

Thanks,
Vivek Anand

Please Note: If my response helps you to fix this issue, please mark it as correct!

Milan13
Giga Expert

Hi Vivek,

unfortunately the notification gets triggered as soon as the date/time field value is changed even after your suggested code change...

Not sure how to pass this date/time parameter to the method...

Thanks anyway,

Milan

Milan13
Giga Expert

Vivek,

 

FYI: I tested this twice and it works 🙂

gs.eventQueueScheduled('on.hold.reminder', current, 'parm1', 'parm2', current.u_on_hold_reminder);

 

Thanks! Milan

 

 

VIVEK ANAND
Mega Guru

Yes, Milan.  

gs.eventQueueScheduled('on.hold.reminder', current, 'parm1', 'parm2', current.u_on_hold_reminder);

Need to pass an Object as 5th parameter.

Thanks,
Vivek Anand

Please Note: If my response helps you to fix this issue, please mark it as correct!