Need to stop a notification through a business rule

sanga2
Tera Contributor

Hi all,

 

We have setup a notification on the update of the additional comments on the hr case ticket. However, we have a requirement where in we need to avoid triggering this notification for the first comment that has been updated on the ticket.

 

I'm trying to trigger the notification through a business rule using the event trigger. Could you please help how can we achieve this functionality. it desnt matter who updated the first comments and what time (could be insert or update). 

9 REPLIES 9

SANDEEP28
Mega Sage

@sanga2 You can use below script to get the list of comments. Here you can write a logic like if number of comments (j.entries.length) is greater than 1 than only trigger event. You can put your table name instead of incident.

 

var j = new GlideSPScriptable().getStream("incident", current.sys_id);

if (j.entries.length > 1) {
write event trigger logic
}

 

You can run this in background script to see list of comments

 

var j = new GlideSPScriptable().getStream("incident", "a1ffe2c187333d04edba9370cbb35d1");

for(var m = 0; m < j.entries.length; m ++) {
gs.print(j.entries[m].field_label + " - " + j.entries[m].value + " - Added By " + j.entries[m].login_name + " - On " + j.entries[m].sys_created_on.toString());
}

 

Refer below article too 

https://www.servicenow.com/community/now-platform-articles/get-complete-activity-log-work-notes-comm...

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

sanga2
Tera Contributor

Hi Sandeep,

 

I want to write a business rule to achieve this. Please help.

@sanga2 Use below script in business rule. Add your event details in eventQueue method

 

(function executeRule(current, previous /*null when async*/ ) {
   
    var getComments = new GlideSPScriptable().getStream(current.getTableName(), current.sys_id);
    if (getComments.entries.length > 1) {
        gs.eventQueue(add your events details);
    }

})(current, previous);

.  

sanga2
Tera Contributor

I have tried by updating the event queue, it didnot trigger the notification after multiple comments update. Please suggest.