Events are getting fired but Notifications are not getting triggered through Schedule Job.

aagman4
Tera Contributor

I am trying to trigger a notification when an Event is fired through Schedule Job.

 

Schedule Job - I selected "Automatically run a script of your choosing" as attached.

Script -

 

var ownerInactive = new GlideRecord('sn_grc_profile');
ownerInactive.addEncodedQuery('owned_by.active=false');
ownerInactive.query();
while(ownerInactive.next()){
gs.eventQueue("sn_grc.entity.owned.by.inactive", ownerInactive, "", "");
}

 

Event - sn_grc.entity.owned.by.inactive on Table - sn_grc_profile

 

Notification - Table - sn_grc_profile

When to send - Event is fired

Who will receive - A group

 

I don't know why notification is not getting triggered with the above configurations. Can someone pls help me on this?

I am stuck on this.

 

 

5 REPLIES 5

Sagar Pagar
Tera Patron

Hi @aagman4,

 

Have you checked the System policy ---> Event logs [sysevent] table and record for fired event. Is state is processed or errors?

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Thanks Sagar for the quick response. I checked today, I don't know how but its working fine now and now I have a new question - What condition I can give on schedule Job Script - Line - ownerInactive.addEncodedQuery('owned_by.active=false');  so that Notification will only be triggered for the newly inactivated owners. Otherwise, it will sent notification for all the entities whose owners are inactive. Please help me on this case.

Sandeep Rajput
Tera Patron
Tera Patron

@aagman4 A couple of things to check on your notification.

 

1. Check if the event name is configured correctly on your notification.

Screenshot 2023-07-30 at 10.17.21 PM.png

2. Check if there are any members added to the group which is selected in Who will receive the notification

3. Check if the users which are members of the group have active checkbox on their sys_user record set to checked.

4. Check if the users which are part of the group have their email ids entered on their user record.

 

Hope this helps.

Thanks Sandeep for the quick response. I checked today, I don't know how but its working fine now and now I have a new question - What condition I can give on schedule Job Script - Line - ownerInactive.addEncodedQuery('owned_by.active=false');  so that Notification will only be triggered for the newly inactivated owner. Otherwise, it will sent notification for all the entities whose owners are inactive. Please help me on this case.