Attach simple document in notification email

tkrishna29
Giga Guru

Hello,

In the email notification, I want to attach a policy document.

I was wondering what was the reason behind not including attach document option straightforward in the email, instead I'm able to attach an image or video. (Image below)

find_real_file.png

Need your advise on the best practice:

1. Where should I upload this document in ServiceNow?

2. How can I just refer it to the email notification.

I have gone through some responses on attaching your incident attachments using some script. In my case, this is a independent document.

Appreciate your help.

Thanks,

Krishna

1 ACCEPTED SOLUTION

If you want to include some information from the parent record, we need to add a bit of scripting to the Notification.   In the Workflow, you will want to add the sys_id of the Integrity record that is triggering the event into the "parm2" parameter (the last parameter in the following call to eventQueue):



gs.eventQueue("x_grs_compliance.investigation.policy", gr, "test@gmail.com", current.getValue("sys_id"));



Now that we are passing on the sys_id, we need to query the Integrity table to get the record and output the information we need.   That will be done in 2 parts:


  1. add a call to a Notification Email Script into the body of the Notification
    find_real_file.png
  2. create a new Notification Email Script
    find_real_file.png

    find_real_file.png
    The script just searches for the Incident record and then uses template.print to output the required data from the Incident record.

I built the example above off the Incident table so you just need to change the table name and then add your fields for your purpose.   That should do it for you.   I ended up with an email like so:


find_real_file.png


View solution in original post

9 REPLIES 9

Thank you Jim. This worked great and I'm almost done.


One last challenge I have his to show the {URI_REF} for the current record in my email.


Can I write that in the email notification script?



My email below:


find_real_file.png


find_real_file.png


Here instead of KB0010059(referring to Knowledge table), I want to show my current concern record reference. Greatly appreciate your help.



Regards,


Krishna


You would have to use something like:



var link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + gr.getLink();


template.print("Click <a href='" + link +"'>" + gr.getDisplayValue() + "</a> to view the concern.");



...in order to display a link.


Jim,


You rock!


shloke04
Kilo Patron

Hi Krishna,



You can make use of "GlideSysAttachment.copy" function by simply writing a Business Rule on the required table with an operation as either Insert or update depending on your requirement with the below code as :



GlideSysAttachment.copy('Source Table', 'Sys Id of Attachment', 'Destination Table', current.sys_id);



Once the Business Rule has been configured, Navigate back to your existing Notification and just marked the Include attachment check box as True.



In my scenario, I was asked to send an PDF file along with Opened Notification for one of the Catalog Items, So I wrote   an after Insert   Business Rule On Requested Item table and my PDF file was attached to one of my Catalog item under Maintain Items module and in order to get the Sys Id of the Attachment, you need to navigate to sys_attachment.LIST table to get the sys id of the file attached to your record.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hello Shloke,


I liked your idea, But, won't it be adding the same document everytime to a new record?


Instead of that, I expected ServiceNow should allow us to upload some documents to your application main table just for once and reuse them in any of our emails / subsequent applications.



Regards,


Krishna