Sending of email notification

Sprankle
Tera Contributor

I have a requirement to send email notification ,if the submitted by and requested for user are same person send only one notification ,if the submitted by and requested for  is different person same induival notification to each of them 

9 REPLIES 9

Mark Manders
Mega Patron

What is your question? Are you running into any issues while implementing this? 

By default, an email is only send once to an email address, even if you are the caller, the requested for, the assigned to and on the watchlist, as long as it is just triggered once. So if you set the recipient to 'requested for' and 'submitted by', they will only receive it once, even if it's the same user.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Its not working if the user is same it is triggering twice 

I just tested it and with me, it works fine. Can you share the setup of your notification? 

 

Also the logs of the email, please. Because it sounds like you are just triggering the email twice (one for each) instead of using the same notification.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Valmik Patil1
Kilo Sage

Hello @Sprankle ,

Create a New Business Rule:

  • Table: Select the appropriate table (e.g., Incident).

  • When: Choose After Insert or After Update (depending on when you want to trigger the event).

  • Condition: You can add a condition to check if the Submitted By or Requested For are different, or use a custom script for more detailed logic.

Below is custom script

(function executeRule(current, previous /* null when async */) {

    var submittedBy = current.submitted_by;
    var requestedFor = current.requested_for;

    // Check if Submitted By and Requested For are the same or different
    if (submittedBy == requestedFor) {
        // Trigger the event for only one recipient
        gs.eventQueue('user.request.notification', current, submittedBy.sys_id, null);
    } else {
        // Trigger the event for both users
        gs.eventQueue('user.request.notification', current, submittedBy.sys_id, null);
        gs.eventQueue('user.request.notification', current, requestedFor.sys_id, null);
    }

})(current, previous);

In this case you need to create event and also notification which should be triggered by event.

Thanks,

Valmik Patil