Need to add two specific attachments to a notification

Moedeb
Tera Guru

I have a notification that gets sent as part of a custom flow and is triggered when a particular event occurs - this is working perfectly.

 

The issue I have is, when that notification sends, I want it to include 2 particular attachments every time it sends.

I have tried the "Include attachments" checkbox in the notification, but that I believe is meant to include any attachments within the triggering record - in this case it would be a RITM, that actually has no attachments, therefore no attachments are added to the notification.

 

I have saved the attachments as part of a knowledge document and their sys_id's are:

Document 1 - 28a3323f11f235103b97b89ea08322d7

Document 2 - 2ca3323f11f235103b97b89ea08322d9

 

Knowledge articles Sys_id - f39272b3117635103b97b89ea083228b

 

The notification has a subject starting with - Security Requirements

 

So what I have tried is to create an advances business rule:

Name: Add attachment

Table: email [sys_email]

When to run = 

when: before 

order: 100

Insert = true (all else false)

 

Conditions:

Subject starts with Security Requirements

 

Advanced Tab:

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

	var sourceID = 'f39272b3117635103b97b89ea083228b';
	var sourceTable = 'kb_knowledge';
	var document1ID = '28a3323f11f235103b97b89ea08322d7';
	var document2ID = '2ca3323f11f235103b97b89ea08322d9';

	GlideSysAttachment.copy(sourceTable, sourceID, 'sys_email', document1ID);
	GlideSysAttachment.copy(sourceTable, sourceID, 'sys_email', document2ID);

})(current, previous);

 

I also added an action to add a message when it runs.

 

The issue I'm having is not only does it still send the notification without attachments, I'm also not getting any message showing that the business rule is even running.

 

Anyone know the right way to do this?

 

I've looked at a few posts here and there and none of them are really helping me, so please don't reply with just a link to another article.

1 ACCEPTED SOLUTION

I know you didn't want links, but this one seems to be directly addressing what you are trying to do;

 

https://www.servicenow.com/community/developer-articles/adding-attachments-to-email/ta-p/2320991

View solution in original post

6 REPLIES 6

I know you didn't want links, but this one seems to be directly addressing what you are trying to do;

 

https://www.servicenow.com/community/developer-articles/adding-attachments-to-email/ta-p/2320991

You are right @Kai Tingey I did specify that I didn't want links to articles, however in this case the article worked 100%, thank you very much for your help, it is certainly appreciated.