Notifications

374 views

Description

You have created an email notification that triggers on a specific event.  The notification is created in a non-Global Domain or non-Global Scope.

The event is created and the notification conditions are all met, and there are one or more recipients correctly defined and configured that should receive the email, but no email record is created.

By checking the Events Log you see the event you created that should trigger the notification (notice the Table field is empty) and at the same time there is a notification_engine.process event with a Parm1 sys_id equal to the notification's sys_id. 

The existence of the notification_engine.process event means that the conditions for the notification have been met.

The following similar logging will be in the node logs when the notification_engine.process event is processed:

2020-04-13 10:40:04 (290) worker.5 worker.5 txid=6030b957db84 *** Start Background transaction - system, user: system
2020-04-13 10:40:04 (296) worker.5 worker.5 txid=6030b957db84 Starting: events process 1.999460131b0100103fc78596dc4bcb41, Trigger Type: Interval, Priority: 25, Upgrade Safe: true, Repeat: 10 Seconds
2020-04-13 10:40:04 (296) worker.5 worker.5 txid=6030b957db84 Name: events process 1
2020-04-13 10:40:04 (427) worker.5 worker.5 txid=6030b957db84 EMAIL.e030f957db8450106f1e74dfaa961965: Notification 'Test Notification' (6b1295dbdb0450106f1e74dfaa9619d0) included recipients via the notification's "Users" field: 'John Doe' (16139f900a0a3ce00120d33ac8629853)
2020-04-13 10:40:04 (439) worker.5 worker.5 txid=6030b957db84 Completed: events process 1 in 0:00:00.139, next occurrence is 04-13-2020 13:40:06

Though the logging may make it appear that the email should be created, there is no sys_email record created.

For example the event for the notification was created as follows:

gs.eventQueue("my_event", current, 'Text for Parm1' , 'Text for Parm2');

In this case the "current" variable does not point to any record object, this is why the 'my_event" event was created with an empty Table field.

Release or Environment

Applies to any release.

Cause

An email notification that is created in a non-global domain or non- global scope that is triggered by an event will not create an email record unless there is an associated record object specified when the event is created.

Because there is no record object, the system is running in the global domain/scope.  Given the notification is not in the global domain or scope, the notification won't trigger.

From above the event is created as follows:

gs.eventQueue("my_event", current, 'Text for Parm1' , 'Text for Parm2');

Where again the "current" does not point to any record object.

On the other hand if the notification is in the global domain and global scope then a record object does not need to be specified, since again the system is running in the global domain/scope.

Resolution

There are two different resolutions to this issue:

Either a record in the domain or scope can be passed to the notification by the event creation or the notification must be placed in the global domain and scope. 

Resolution #1:

If the notification remains in the non-global domain/scope the event needs to be created with a record object defined in the second parameter of eventQueue.  This puts the system into the domain/scope of the notification.

Change the way the event is created, from this:

gs.eventQueue("my_event", current, 'Text for Parm1' , 'Text for Parm2');

To this:

var myGlideRecord = new GlideRecord('sys_user');
myGlideRecord.addQuery('sys_id','16139f900a0a3ce00120d33ac8629853');
myGlideRecord.query();
if(myGlideRecord.next())
{
gs.eventQueue("my_event",myGlideRecord, 'Text for Parm1' , 'Text for Parm2');
}

This is just associating the event to a record in the sys_user table.  The record used is not important.

If the event is viewed in the event log you will notice that now the Table field will now be populated.

 

Resolution #2:

Move the notification to the global domain and global scope.  In this configuration the event creation does not need to point to a record object since again the system will be running in the global domain/scope which will match the domain/scope of the notification.

Article Information

Last Updated:2020-06-17 23:08:11
Published:2020-04-15