How to attach PDF to the email notification in flow designer

Harithapola
Tera Contributor

I have a catalog item, when submitted it checks if the type is resource onboarding, if yes then it has to send an pdf document as an attachment to the user in an email . I want to achieve this in flow designer.

1 ACCEPTED SOLUTION

@Harithapola 

so it's a standalone PDF.

You can create a system property and add PDF to that property 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-1749660356692.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

18 REPLIES 18

The pdf is not stored on the RITM record

@Ankur Bawiskar Could you please let me know how to attach the pdf document to the RITM?

@Harithapola 

so it's a standalone PDF.

You can create a system property and add PDF to that property 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-1749660356692.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

@Ankur Bawiskar , So for this does this send pdf in the email notification to the user?

@Harithapola 

yes it should work fine as it has worked earlier as well.

Unless you try you won't know.

I believe I have answered your question with relevant scripts, links etc and you can enhance it further from here.

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