Duplicate work note notifications sent out when work notes are generated rapidly

Chris Petrone
Tera Expert

We are having an issue with duplicate work note notification emails getting sent out in a specific scenario.

We use Remote instance spoke.

When we trigger a task on our end to send over to the remote instance, this is when our issue starts.

The remote instance is programmed to work note most of their updates to their tickets. These work notes get sent to our task. 

So for example: remote instance types a work note into their field, and also makes a change to the state of their ticket, clicks on Save record. The change on their end triggers a work note to be printed, which gets sent to our instance. 

1 work note get printed stating the remote instance has changed their state, since we want to know when that happens, and a second work note is printed on the actual work note typed up.

This comes through as 2 work notes on our end within 0-2 seconds of each other.

We now have an email notification that gets triggered any time a work note is added to the task, and gets sent out to the assigned to user. Because the work notes have come through so quick, the email notification sends out an email for 2 work notes, since there were 2, but it only grabs the last work note on the task, making it look like duplicate notifications got sent. The notification is not fast enough to get the first work note when work notes come through in quick succession.

 

What would be a good solution for this? ServiceNow states "email notification is working as expected.
Due to the fact that all the changes to the task occur simultaneously, using RIS, on your local instance.
The work_note gets added to the email notification using the value of the most recent entry in the work_notes.
At the time that both notifications were triggered, the work notes had already been updated with all the updates, but only the most recent is added into both the notifications."

6 REPLIES 6

Chaitanya ILCR
Kilo Patron

Hi @Chris Petrone ,

you can try this approach

 

  1. Create a copy of the email notification but this time, use an event trigger and disable the current one.
  2. Create a new event in the event registry.
  3. Create a "Before Update" business rule with the condition that triggers when work notes change (add any additional conditions if needed).
  4. Fire the event with the work note value as one of the parameters.
  5. Use the event parameter value in the email notification.

 

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

Regards,
Chaitanya

Vishal Jaswal
Giga Sage

Hi @Chris Petrone 

If every time, the first work note string is same/constant which is "the remote instance has changed their state" then you can try below in the Advanced Condition of e-mail notification. This will not send an e-mail whenever the latest journal entry of the record (incident in my example) contains this work note string:

 

(function executeRule(current) {
    var targetedStr = "remote instance has changed their state";
    var foundtargetedStr = false;
    var journalGR = new GlideRecord('sys_journal_field');
    journalGR.addQuery('element_id', current.sys_id); // Match work notes related to current Incident
    journalGR.addQuery('element', 'work_notes'); // Filter only work notes
    journalGR.orderByDesc('sys_created_on'); // Get the latest work note first
    journalGR.setLimit(1); // Only check the most recent work note
    journalGR.query();
    if (journalGR.next()) {
        var latestWorkNote = journalGR.getValue('value');
        //you can use either of below two
        // if (latestWorkNote.includes(targetedStr)) {	
        if (latestWorkNote && latestWorkNote.indexOf(targetedStr) !== -1) {
            gs.log("Email not sent due to matching work note: " + targetedStr);
            foundtargetedStr = true;
        }
    }
    return !foundtargetedStr; // Return false if str is found
})(current);

 

 

vishal_jaswal_3-1741128539137.png

 

vishal_jaswal_4-1741128550535.png

 


I tried the same in PDI and it worked:

vishal_jaswal_0-1741128481514.png

vishal_jaswal_1-1741128491635.png

vishal_jaswal_2-1741128516488.png

 


Hope that helps!

Thanks for the reply. Unfortunately, the first work note is not the same. It could be any field that they update that triggers a work note back to us that we need to know; state change, assignment group/user change, priority/impact change, etc. SInce out instances do not match with these fields, we tell each other in the work notes when one of these fields changes, but when they change multiple things on their side, each of them prints their own work note out causing them to come in all at the same time, and then triggering our work_note email notification to trigger for as many work notes that came through, but only grabbing the last work note that was made on the task, unfortunately too late as the email notification is too slow to get the previous ones.

1. If State changed at remote instance added a work note at your instance which triggers an e-mail notification, then you can modify the email notification based upon updated by and on specific field changes.

 

2. Actual work note added like “I have accepted it” at remote instance is also a work note added at your instance which triggers another e-mail. Just asking whether you planned it this way or never thought of replicating their work note as an additional comment. If you can replicate their work note as additional comment then you can modify your notification.


Hope that helps!