Attachment to the notification

Bonam Yasaswini
Tera Contributor

I need a specific pdf document to be attached physically to the email notification when it's sent out. It shouldn't be a link to the pdf but it should be a physical file where the users can access the pdf without Servicenow access. How can it be achieved? Also, I need to know how to test the whether the attachment is included or not in email logs? Thanks in advance.

 

2 ACCEPTED SOLUTIONS

@Bonam Yasaswini 

yes it's possible. but the file has to be stored in some record.

I shared solution for something similar 2 years ago

Adding latest attachment from sys_attachment table to sys_email record 

1) create a system property and add your file to it

2) then create after insert BR on sys_email with condition as this

You change the table as sc_req_item

AnkurBawiskar_0-1736317663024.png

 

 

BR script

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

        var propertyRecordSysId = ''; // give here the sysId of newly created system property record where file is present
	var s_Attach = new GlideRecord('sys_attachment');
	s_Attach.addEncodedQuery('table_sys_id=' + propertyRecordSysId);
	s_Attach.query();
	if(s_Attach.next()){
		var rec = new GlideRecord('sys_email_attachment');
		rec.initialize();
		rec.attachment = s_Attach.sys_id;
		rec.file_name = s_Attach.file_name;
		rec.source = 'notification';
		rec.content_disposition = 'attachment';
		rec.email = current.sys_id;
		rec.insert();
	}
})(current, previous);

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

@Bonam Yasaswini 

yes if it comes in email attachment tab then it will be sent, it's OOB

Thank you for marking my response as helpful.

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

9 REPLIES 9

@Bonam Yasaswini 

yes if it comes in email attachment tab then it will be sent, it's OOB

Thank you for marking my response as helpful.

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

@Bonam Yasaswini 

I believe you should mark this response correct as well so that it helps future readers.

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

Viraj Hudlikar
Tera Sage

Hello @Bonam Yasaswini 

As suggested by Ankur you can configure over your notification which you have setup which will be triggered on your conditions. See below snip where you need to configure over your notification.

Notification.png

 

For testing part in your lower instance, you can set the trap email to your email and enabling email sending property as true. See below snip to configure over lower instance and make sure you revert it back after your testing.

email property.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

@Viraj Hudlikar 
Is there any way of adding it in the email instead of adding the file on every ritm rceord? Since the RITM is the trigger record for this notification.

@Bonam Yasaswini 
We are not adding on every RITM record as I believe that notification you created is specific for Catalog Item. If not, then try to create a separate notification which will be triggered for this particular catalog item based on your condition and the one which is sent for all there you can exclude that catalog item in conditions. 
Note - Attachment will be on notification and as shared in above reply check how to configure it.

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.


Thanks & Regards
Viraj Hudlikar.