Don't want to trigger the notification..

Devansh1
Tera Contributor

Hi All,

I don't want to trigger the notification when any attachment is added or deleted,

actually we are getting the ticket from the record producer and there is activity whenever any attachment will add or delete it is saving in the comments,  and we have written condition in the notification to run whenever the comments changes and this notification goes to requested for. 

So how can i prevent the nofitication just for the attachments.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Devansh1 

use this script in the advanced notification condition

var commentText = current.comments.getJournalEntry(1);
if (commentText.indexOf('deleted an attachment') > -1 || commentText.indexOf('added attachment') > -1) {
    answer = false;
}
else{
answer = true;
}

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

Chaitanya ILCR
Kilo Patron

Hi @Devansh1 ,

two ways you can achieve this

 

1. fine the BR or whatever is adding the comment and add setWorkflow(false) to it 

 

or 

 

in the notification condition add this below code

 

ChaitanyaILCR_0-1757067844639.png

answer = true;

var jfGr = new GlideRecord('sys_journal_field');
jfGr.setLimit(1);
jfGr.addEncodedQuery('element=comments^element_id=' + current.getValue('sys_id'));
jfGr.orderByDesc('sys_created_on');
jfGr.query();
if (jfGr.next()) {
    if (jfGr.getValue('value') == 'deleted an attachment' || jfGr.getValue('value') == 'added attachment') {
        answer = false;
    }
}

  

 

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

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@Devansh1 

use this script in the advanced notification condition

var commentText = current.comments.getJournalEntry(1);
if (commentText.indexOf('deleted an attachment') > -1 || commentText.indexOf('added attachment') > -1) {
    answer = false;
}
else{
answer = true;
}

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

It's working

Many thanks