How to use the Triggered condition for an Email Notification?

ChuanYanF
Tera Guru

Dear experts,

 

I want to know how do we use this condition for an email notification when to send is When Triggered, I configured an email notification for monthly KRI Email Reminder and scripted a scheduled job script which is as below but it is not triggering the email to send. Any approach or missing steps I need to do?

// Create a GlideNotification object
var notif = new GlideNotification();

// Specify the notification name (use the sys_id or the name of the notification)
notif.setNotification('KRI Email reminder');

// Optionally, specify a target record for the notification (null if not needed)
var targetRecord = null; // You can specify a record, or leave it as null

// Send the notification
notif.send(targetRecord);

// Log that the email was triggered
gs.log('KRI Reminder email sent successfully on the 24th', 'KRI Reminder');
3 ACCEPTED SOLUTIONS

Chaitanya ILCR
Kilo Patron

Hi @ChuanYanF ,

 

Triggered type notifications are used in the flows.

In this scenario, if you want to use a scheduled job, create an event and fire the event. Then, update the notification's "Send When" setting to "Event is fired" and select the newly created event.

Alternatively, you can use the flow and utilize the "Send Notification" action, ensuring the notification type is set to "Triggered."

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

Shivalika
Mega Sage

Ok @ChuanYanF 

 Apologies, you are talking about when "When to Send is Triggered" in the notification form itself. 

 

That triggered is used when its "TRIGGERED BY ACTION IN FLOW DESGINER" 

 

Refer this documentation - 

https://www.servicenow.com/docs/bundle/yokohama-build-workflows/page/administer/flow-designer/refere...

 

Shivalika_0-1744178838306.png

 

 

Shivalika_1-1744178895150.png

 

 

Hope this answers your query, that's not for scheduled job. In scheduled job you will need "gs.eventQueue()" - as I had replied in my previous reply. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

Robert H
Mega Sage

Hello @ChuanYanF ,

 

Please note that GlideNotification is meant for showing a notification on the user's screen, it's not meant for email notification.

 

Here are the steps for triggering an email notification from a script:

 

Step 1: go to System Policy > Events > Registry and create a new event, e.g. "kri.reminder"

 

Step 2: configure your Notification like this (but select your own "kri.reminder" event here):

RobertH_0-1744178932684.png

 

Step 3: in your Scheduled Script, add this line. Note: "gr" is the GlideRecord of the record that this notification is about. If it's not about a record you can replace it with null.

gs.eventQueue('kri.reminder', gr);

 

Regards,

Robert

 

 

View solution in original post

4 REPLIES 4

Shivalika
Mega Sage

Hello @ChuanYanF 

 

You need to create an event. 

 

use this format in the scheduled job - gs.eventQueue('event_name', current, parm1, parm2) - params is whatever you pass in the data from your scheduled job if you want to pass any. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Chaitanya ILCR
Kilo Patron

Hi @ChuanYanF ,

 

Triggered type notifications are used in the flows.

In this scenario, if you want to use a scheduled job, create an event and fire the event. Then, update the notification's "Send When" setting to "Event is fired" and select the newly created event.

Alternatively, you can use the flow and utilize the "Send Notification" action, ensuring the notification type is set to "Triggered."

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Shivalika
Mega Sage

Ok @ChuanYanF 

 Apologies, you are talking about when "When to Send is Triggered" in the notification form itself. 

 

That triggered is used when its "TRIGGERED BY ACTION IN FLOW DESGINER" 

 

Refer this documentation - 

https://www.servicenow.com/docs/bundle/yokohama-build-workflows/page/administer/flow-designer/refere...

 

Shivalika_0-1744178838306.png

 

 

Shivalika_1-1744178895150.png

 

 

Hope this answers your query, that's not for scheduled job. In scheduled job you will need "gs.eventQueue()" - as I had replied in my previous reply. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Robert H
Mega Sage

Hello @ChuanYanF ,

 

Please note that GlideNotification is meant for showing a notification on the user's screen, it's not meant for email notification.

 

Here are the steps for triggering an email notification from a script:

 

Step 1: go to System Policy > Events > Registry and create a new event, e.g. "kri.reminder"

 

Step 2: configure your Notification like this (but select your own "kri.reminder" event here):

RobertH_0-1744178932684.png

 

Step 3: in your Scheduled Script, add this line. Note: "gr" is the GlideRecord of the record that this notification is about. If it's not about a record you can replace it with null.

gs.eventQueue('kri.reminder', gr);

 

Regards,

Robert