How to configure a notification for a custom event for Integartion success or fail

raj12345
Tera Contributor

 

Hi Community,

I have a scheduled job that syncs user data from ServiceNow to Greenhouse via their API. Once the job completes, I want to trigger a notification indicating whether the sync was successful or failed.

I'm using a custom event like this in my script:

 

Passed in Schdeule Job
gs.eventQueue('event', null, gs.getUserName(), message);

Since I passed null as the GlideRecord, the event is not tied to any specific table. However, when setting up the notification in System Notification > Email > Notifications, the Table field is mandatory.

My Questions:

  1. What table should I select for this kind of generic/global notification?

  2. Is selecting the Global table the best practice in this case?

  3. Are there any potential issues I should be aware of when triggering events like this without a record?

Appreciate any guidance or best practices!

Thanks in advance. 

1 ACCEPTED SOLUTION

@raj12345 

Would you mind closing your question by marking appropriate response as correct?

Members have invested their time and efforts in helping you.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@raj12345 

you can use GlideEmailOutbound API syntax to send email and don't use eventQueue()

something like this

 var email = new GlideEmailOutbound();
            email.setSubject("Open Tasks Notification");
            email.setBody(emailBody);
            email.setRecipients(userEmail); // Send to the assigned user's email
            email.save();

GlideEmailOutbound() 

GlideEmailOutbound - Scoped 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar 
Are you please able understand my use case??

 

@raj12345 

I am just saying from wherever you are checking API failure don't use event, notification

You can simply use that GlideEmailOutbound API and send email and you need not create event on some table, notification on some table

Please share how are you checking API failure and the script from scheduled job

something like this

if (API failure) {
    var email = new GlideEmailOutbound();
    email.setSubject("API Failed");
    email.setBody('Your email body html or plain text');
    email.setRecipients(userEmail); // send to some static email
    email.save();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@raj12345 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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