Using Create Event to send Notification from Workflow with Attachment

Steven Parker
Giga Sage

So this is my Create Event in the workflow (the "event name" and email notification are each on the SC_TASK table)

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

So it sends the notification, but doesn't include the PDF attachment on the email...I thought that "Include Attachments" check box would attach the file to the email it sends.  I've even placed the PDF file on the "Create Event" in the workflow, the event itself in the registry, and on the notification, but the attachment just doesn't attach to the email.

How do I get that PDF file to attach to the email? Not a link...just actually attached to the email. 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
21 REPLIES 21

You need to write email script to get actual PDF attached to outgoing email.

In email script, you can refer sys_attachment table to find out PDF file which you need to sent alongwith email notification.

 

You need to refer mail script from mail notification to make this work.

 

 

Regards,

sachin

I am trying to do that now, but must be missing something.  Is there a specific table the Notification and Event registry record should be on if I am calling the notification from an event in the workflow? Here is my notification and the mail script to attach the file:

find_real_file.png

 

find_real_file.png


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

Your notification should be on sc_task table since you configured event on sc_task table.

Also, use below mail script

 

<mail_script>


attachLinks();


function attachLinks() {


       //Check for any attachments and add attachment links if they exist


       var gr = new GlideRecord('sys_attachment');


       gr.addQuery('table_sys_id',current.sys_id);


       gr.query();


       if(gr.hasNext()){


             template.print('Attachments: \n');


                   while (gr.next()) {


                         var attachLink = '<a href="' + gs.getProperty("glide.servlet.uri") + gs.generateURL(gr.getTableName(),gr.sys_id) +   '">' + gr.file_name + '</a>';


                         template.print(attachLink +   '\n');


                   }


             template.print('<hr/>');


       }


         


       var task = new GlideRecord('sc_task');


       task.addQuery('request_item',current.sys_id);


       task.query();


       while(task.next())


       {


           var gr1 = new GlideRecord('sys_attachment');


       gr1.addQuery('table_sys_id',task.sys_id);


       gr1.query();


       if(gr1.hasNext()){


             template.print('Attachments: \n');


                   while (gr1.next()) {


                         var attachLink = '<a href="' + gs.getProperty("glide.servlet.uri") + gs.generateURL(gr1.getTableName(),gr1.sys_id) +   '">' + gr1.file_name + '</a>';


                         template.print(attachLink +   '\n');


                   }


             template.print('<hr/>');


       }



         }


}


</mail_script>

 

Regards,

Sachin

I am not trying to use links.  I can already do that.  I am trying to attach the actual file to the email notification that goes out.  

I have both the event and notification on the wf_activity table because that's where the attachment was on the attachment table.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

Steven Parker
Giga Sage

Does anyone know how to just attach a PDF to a notification?  Not a link, not a url, just attach the file and send it.

It seems odd to me that you can create events, fire notifications off the events, even check a box that says "Include Attachments", but no attachments on the notification get sent.  It sounds like it's looking for attachments on the Request to send, but I just want to fire off a notification at a certain point with a file attached that the end user can open directly...not a link to anywhere.

Is this not possible?


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven