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

Jim Coyne
Kilo Patron

Hello Jim,


Thank you for your response. I'm getting the attachments from kb_knowledge.


However, I'm unable to display the current record values of my workflow along with the attachment. Since the current record is from kb_knowledge.


The below script is triggered from workflow. The workflow triggers on Integrity table and I want to display the current values of Integrity values along with the attachment from kb_knowledge.


find_real_file.png


Please see my configuration below -


find_real_file.png


find_real_file.png


find_real_file.png


Email output shows blank values:


find_real_file.png


How can I pass the current records values to the event that I fire? Thank you.



Regards,


Krishna


KIndly appreciate if anyone can help on this. If I cannot attach the document, I want to able to keep a link to the policy document atleast in the email.


I tried that by creating a article in knowledge with article as attachment.


find_real_file.png


And I kept the link in the email.


https://xxxxxxx.service-now.com/sys_attachment.do?sys_id=b1ac0fa7db99fa003a22fbb9af96190b


This works fine but it doesnt look like a best practice as I have to do the same manually in TEST & PROD systems.



Can someone suggest the best practice to have the policy document link in the email and where should I actually have the file?


OR would be great if I can attach the document directly on how Jim suggested.



Appreciate your help.


Thank you,


Krishna


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