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

GlideFather
Tera Patron

Hi @Devansh1,

 

as per the conditions - Additional comments [changes] - it would trigger the notification always when a comment is added...

 

If you want to send this notification only when an attachment is added and only upon the submission and never ever after that - it will require some adjustments.

 

I don't have it tested but quick brainstorming.. I have a few ideas..... However the easiest one would be this:

 

  • hide the attachment section on that particular item (right side of screenshot below)
  • and add a new variable type attachment (the left side)

GlideFather_0-1757067348655.png

 

With that users can only attach the attachment using the variable, this will give you easy way how to find if the attachment is added or not... you can make even it mandatory upon conditions (catalog ui policy + action).

 

And if the variable is populated you can mark some field or trigger event and based on this you will trigger the notification. I believe it is way better than comment is added...

 

Let me know how does it sound to you

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


@Devansh1 

another idea was a BR checking sys_attachment table and if it was related to the catalog item, then it would fire an event and this event would trigger the notification

 

other ideas seem silly now...

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Actually the thing is i don't want to trigger the notification when attachment added or deleted

So i have written script into the advances condition under the notification .

 

var commentText = current.comments.toString();

 

if (commentText == 'deleted an attachment' || commentText == 'added attachment') {
    current.setAbortAction(true);
}
with this condition it is not triggering even for the other comments as well
Can i do this via BR  if yes how?

Bhuvan
Tera Sage

@Devansh1 

 

Check for any BR on sys_attachment table to add work notes in related table when attachment is inserted or deleted. Carefully consider your requirements and change the BR filter conditions to not add work notes.

 

Also check if you have any script action created for addition or deletion of attachments to incident. Below is for reference,

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0825660

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan