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

Milan13
Giga Expert

Just one more question, after the event is triggered (gs.eventQueueScheduled) I need field "state" to be set to one of the choices which is "assigned" and field "assigned_to" needs to be empty.

I tried this but it does not work...

Any idea how to do this? Many thanks 🙂

Milan

(function executeRule(current, previous /*null when async*/) {

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

if(gs.eventQueueScheduled('on.hold.reminder', current, 'parm1', 'parm2', current.u_on_hold_reminder)) {
current.state = 'Assigned';
current.assigned_to = "";
current.update();
}




})(current, previous);

Milan13
Giga Expert

Maybe script action is better?

Yes, if you want to schedule this change after you trigger your notification, you can configure a script action. You are right.

Thanks,
Vivek Anand

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

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!

I tried this in script action and it just does not work, not sure why...

 

setIncFields();

function setIncFields() {
current.state = 'Assigned';
current.assigned_to = '';
current.update();
}

Any idea?

Many thanks, Milan