- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 03:22 AM
Hi,
I have a process where the ess user creates a new service catalog item and attachs a document. (the attachment button is a variable that looks up a macro).
The workflow then sends a sc task to a new set of users and another attachment is added.
1. My first issue is that i need to attach the documents to the Approval notifcations (i have ticked the 'include attachment' in the notification and nothing happens?)
2. I also need the attachments to appear in a final workflow email notifcation. I have added in the following mail script to my workflow notification which works fine for the SC Attachment, but this doesn't attach my other document which was uploaded in the Catalog Task:
Any help will be greatly appreciated.
<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/>');
}
}
</mail_script>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 01:58 PM
Kathryn,
Change the Script to :
<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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 04:15 PM
To make sure you get all attachments that are there at the time the Notification is sent, a mail script in the Notification itself should do the trick. I haven't tested this, though. It's possible the Notification grabs the attachments before the script executes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 04:37 PM
Good afternoon,
In my situation, the attachment is on my Request Item. Is there a way for the email notification (from workflow, not event) to take this attachment and include it in the email as a proper attachment rather than a link? The email notification will be sent to non-ServiceNow users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 05:39 AM
Shane C - did you ever figure this out?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 09:02 AM
Unfortunately, I did not. I ended up creating an event in my workflow and having that event trigger an email notification running off of the request item table. If you turn on the option to "Include attachments", the user's document they are attaching when ordering your catalog item will be included in the notification going out. Give it a shot and let me know if you run into any snags!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2017 11:12 AM
Shane
Can you screenshot what your event looks like for triggering the email notification?
I've created the notification already on the requested item table, but new to this Event item in a workflow.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven