Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Generate pdf document from template and attach that document into one email in flow designer

Debasis Pati
Kilo Sage

Hello All,
I have a requirement i have some tempaltes and template mappings done in sn_doc_template table.
Now i have to generate pdf document using flow designer and after it gets generated i need to attach that generated document as an attachment to one email using flow designer.

@Ankur Bawiskar , How i can achive this functionality?


2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Debasis Pati 

I have a blog and you can use that server side script in custom flow action and include that flow action in your flow

Generating and Attaching Document Templates in ServiceNow to Record - Server Side 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader


Hello @Ankur Bawiskar ,
The below is the script i tried my template is a word template and applied table is a custom table i tried but the info is coming as undefined.
(
function executeRule(current, previous /*null when async*/ ) {

    var documentTemplateId = '8833b032c1c7c31002c66daf4c587837';
    var recordId = current.sys_id;
   // var documentTemplateId = '50e6c385db175e10727ee7dcd39619f2';
    var pdfName = 'INC_Template.pdf';
    var s=new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);
    gs.info("xdwhjvcdvcjh----"+s);


})(current, previous);