The CreatorCon Call for Content is officially open! Get started here.

Getting attachment in Email rather than link

habin
Kilo Contributor

Hi ,
I have a requirement to get all the attachment of an incident ticket in the mail notification(not as a link). I was able to send the links of attachments through notification.

Could any one please tell how can I accomplish it.

Thanks in advance.

Habin

18 REPLIES 18

Jim, the "Include Attachments" option means include the attachment from the record that generated the notification. For example if an incident has attachments and the system sends a notification, you can opt to send the files from the incident.


John, thanks for the information. When I attach the attachment to the requested item that was created by my Catalog request, the email notification that is sent out has the attachment. Now I need to find a process that will copy the attachment from my catalog item to the requested item then notification will send the attachment. Jim


hollandrs
Kilo Explorer

The easiest and most simple way of doing this is at this source link.

http://www.snc-blog.com/2011/11/23/pre-attached-attachments-for-the-servicenow-email-client/

It attaches the documents to the email. It also shows how to make the UI Page updates so that it properly shows when a document is removed after it has been attached in this method. Thereby allowing the user to decide whether he wants to send all of the attachments, some or even those that have already been sent.

Sean


dschaefer
Mega Expert

I realize this is years later (Jan 2017), but just in case anyone's looking for an update on this issue, here's how I solved this problem:



1. Add a "Sent" field to the sys_attachment table. The column name should be "u_sent", and it is of type "True/False", and it defaults to false.



2. Create a business rule against the "sys_email" table. It should run before insert. No filter conditions. No actions. The script (under the "Advanced" tab) should be as follows:



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


  var gr = new GlideRecord('sys_attachment');


  var table = '';
  gr.addQuery('table_sys_id',current.instance);
  gr.addQuery('u_sent',false); // look for attachments that have not yet been sent
  gr.query();
  while(gr.next()) {
      gr.u_sent = true; // mark so that we don't send again
      gr.update();
      table = gr.table_name;
  }
  if (table != '') {
      GlideSysAttachment.copy(table,current.instance,'sys_email',current.sys_id);
  }
})(current, previous);



3. Note difference in this script from the above entries. Most notable is that the function "Packages.com.glide.ui.SysAttachment.copy" has been replaced with "GlideSysAttachment.copy". This change has been implemented in the Calgary release. Also, we only define a value for table if there is an update -- any update -- in the list of attached files. The GlideSysAttachment.copy function grabs all attachments and sends them out.



I implemented this function on my system (running Helsinki), and it appears to work well.



-Dan


gbade
Kilo Contributor

Hi Dan,


will this work for RITM?, tried the script in a BR for sys_email table but doesn't work. ( sure am doing something wrong)!


Basically, I want the attachment to show in the approval notification email the approver gets.



In my workflow for requested items, I have a task where an itil user has to attach a document for review by the approver.


when the task is closed, an approval request is generated.


so when the approver gets the email, I want the attachment to show in the email.   Most of the approvers are not itil users so they need to be able to see this in an email.



tried the include attachment feature in notification but it doesn't work. pls see below


find_real_file.pngThanks for any assistance