How to call the multiple events in the one Notification

is_12
Tera Contributor

Hello Community !

 

I need create one new notification when the needs attentions is true on the sc_task

For this

Trigger condition: 1. state changes from Pending to Work in progress

2.Additional comments updated by customer/ not assigned to

3.Catalog type is SSR

 

Should I need to create a multiple events for each one of  this three conditions, if so then how to implement that.

If not how to achieve this.

 

 

Looking forward for the working solution

Thank you 

2 ACCEPTED SOLUTIONS

@is_12 

Don't use Event, let notification get trigger based on updated checkbox on sc_task table

for checking this -> 2.Additional comments updated by customer/ not assigned to

You can use advanced notification condition and script

Something like this and enhance it further

AnkurBawiskar_0-1746778176695.png

 

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

@is_12 

then use toString() to compare and also use gs.getUserName() to get user ID at line 10

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    gs.info('userID7');

    var comments = '';
    var userId = gs.getUserName(); // Get the logged-in user ID
    gs.info('userID9' + userId);
    var requestorId = current.request_item.requested_for.user_name.toString();

    gs.info('userID14' + requestorId);

    var gr = new GlideRecord('sys_journal_field');
    gr.addQuery('element_id', current.sys_id);
    gr.addQuery('element', 'comments');
    gr.orderByDesc('sys_created_by');
    gr.query();

    gs.info('userID14' + requestorId);
    gs.info('created by' + gr.sys_created_by);
    if (gr.next()) {
        gs.info('userID25', +comments);
        if (gr.sys_created_by.toString() == userId || gr.sys_created_by.toString() == requestorId) {

            gs.info('userID23' + comments);
            comments += gr.value + '\n';
        }
    }

    gs.info("userID32" + comments);
    template.print('The task ' + current.number + ' has been updated by the customer with below comments ' + comments + '\n');


})(current, template, email, email_action, event);

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

15 REPLIES 15

Service_RNow
Mega Sage

@is_12 

 

In ServiceNow, if you want to trigger multiple events from a single notification, it's important to understand that:

  • Notifications are generally tied to a single event.

  • However, multiple events can each trigger the same notification (or different ones).

  • You can't directly call multiple events within a single notification setup — instead, you architect the system so that multiple events are either triggered together or handled in script logic.

Options for Achieving "Multiple Events" in One Notification

Option 1: Trigger a Single Event That Embeds Multiple Conditions

  • Design one custom event that encapsulates all the logic needed.

  • In the notification script (or advanced condition), handle what message to send based on the context.

Example:

 

javascript
 
if (event.parm1 == 'incident_closed') { // do something } else if (event.parm1 == 'reopened') { // do something else }

Option 2: Use a Script Action to Trigger Multiple Events

If you're using a Business Rule or Script Action, you can manually fire multiple events.

Example:

 

javascript
gs.eventQueue("custom.event.1", current, current.sys_id, "data1"); gs.eventQueue("custom.event.2", current, current.sys_id, "data2");

Then, in the Notifications table, create separate notifications for each event and tailor them accordingly.

Option 3: Use Event Name Pattern Matching

Have multiple events that follow a naming pattern, and use the same notification for all of them.

Example:
If events are named like custom.update.a, custom.update.b, etc., you can create a notification with a scripted condition:

 

javascript
currentEvent.name.startsWith('custom.update');

Option 4: Handle Complex Logic in Notification Script

Instead of trying to merge events, keep the logic in the notification template. You can access event.parm1 and event.parm2 inside the notification template or condition script to change the message dynamically.


Summary

You can't directly bind multiple events to one notification through the UI, but you can:

  • Trigger multiple events through scripting.

  • Use one custom event to represent multiple scenarios.

  • Use logic in the notification's condition or template to handle different use cases.
    Hope the answer has helped you, please mark the answer correct/helpful. Thank you.

Ankur Bawiskar
Tera Patron
Tera Patron

@is_12 

1 email with the above condition is good enough.

Why you want to use events since you are directly using notification to determine the trigger?

Ensure all the conditions satisfy when you are testing

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

Hello @Ankur Bawiskar 

For adding the condition additional comments changes by customer in the record updated or inserted I'm not able to add the exact conditions, only it is showing additional comments changes

So I though to add the event based notification, I created one event for additional comment changes and other two I add has filter condition in the notification, but I'm getting this error

is_12_0-1746775724544.png

 

@is_12 

Don't use Event, let notification get trigger based on updated checkbox on sc_task table

for checking this -> 2.Additional comments updated by customer/ not assigned to

You can use advanced notification condition and script

Something like this and enhance it further

AnkurBawiskar_0-1746778176695.png

 

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