Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How should an event be ignore/abort/cancel in an event queue?

trangdan106
Tera Contributor

Hello eveyrone,

I have an email fired by an event. This event is added to the sysevent queue using "gs.eventQueueScheduled()" so when it is added it will be in "Ready" state and wait for a moment before being processed.

 

I have the requirement where I have to cancel/abort this event while it is in "Ready" state. My current solution is using the "Error" state of the event with a message in parm1 as there is no cancel or ignore state and I can't delete said event because of audit.

 

I'm wondering are there any other better practice or appoarch for this. I also have found something related to event ignore but it is for em_alert/em_event which is event and alert for 3rd party apps such as SCOM, etc. so not related to this.

 

Much thanks.

3 REPLIES 3

vaishali231
Kilo Sage

Hey @trangdan106 

Using the Error state to cancel an event is not recommended. It misrepresents system behavior, pollutes logs, and can create confusion during monitoring or audits.

In ServiceNow, there is no OOTB “cancel” mechanism for events in Ready state, so the correct approach is to control the downstream action (email), not the event itself.

 

Approach

1) Control Email via Notification Condition 

Allow the event to be processed, but prevent the email from sending using a condition.

Example:

answer = !current.u_cancel_email;

You can set u_cancel_email = true during the delay window before the scheduled event is processed.

Why this works well:

  1. Keeps event processing clean and intact
  2. Fully aligned with platform design
  3. No impact on audit/history
  4. Easy to maintain

 

2) Use a Flag-Based Cancellation Pattern

Since you are using gs.eventQueueScheduled(), you already have a delay window.

Implementation:

  • Schedule event:

gs.eventQueueScheduled('my.event', current, '', '', scheduleTime);

 

 

  • During delay, update record:

current.u_cancel_email = true;

current.update();

 

 

  • Notification checks the flag and skips sending

 

3) Advanced Option (if needed)

For more complex scenarios, you can:

Add logic in Advanced condition script of the notification

Or use a Script Action to conditionally stop execution

 

What to Avoid

  • Setting event state to Error
  • Deleting records from sysevent
  • Directly manipulating event queue records

These approaches are not aligned with best practices and can lead to audit and supportability issues.

************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb



 

I can't create another field for the record. However, I can update the sysevent parm1 and parm2. During the wait window, I can update the parm1 to "Cancelled" and create a condition in the advance condition section of the email to check for this keyword.

Ankur Bawiskar
Tera Patron

@trangdan106 

so you are scheduling the email at later stage using gs.eventQueueScheduled()

Under what condition the email should not go?

Why not send the email when the actual condition satisfies?

You can use flow to wait for that duration and then if your condition matches/evaluates to true then send the email using "Send Email" flow action

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader