
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2015 12:42 PM
Hello all,
I am working on a vendor project and having an issue with attachments in notifications. I have two PDF attachments that I am trying to include in a notification that goes out to an external customer (outside of our ServiceNow). I have written the email script and added it to the notification body to include the attachment and it works. The problem that I am having is that in order to open the document, the user must be signed in to ServiceNow, otherwise, they are not able to open the document. Has anyone been able to send notifications from servicenow with attachments to an external user that does not require to log in to the instance? I have attached some screenshots for you to see. Please let me know of any ideas.
Email script:
part of the notification (i have checked the "Include attachments" box but that didn't make a difference.
email the user should receive:
when clicking on the links, this is what the user gets:
Please let me know of what I can do to fix this issue.
Thank you!
Yeny Garcia
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2015 10:37 AM
Hello all,
I was able to get this working using a business rule to attach the documents to the email. I hope that this helps other users also who are stuck on the same issue.
First, attach the documents to the notification that will be triggered. Then create a business rule on the sys_email table.
BR
When: Before, Insert
Condition: current.mailbox.getDisplayName() != "Sent" && current.subject == "NEW APPROVED VENDOR EMAIL"
Script:
var strTemp = '';
var attachment = new GlideRecord('sysevent_email_action');
attachment.addQuery('name', 'CONTAINS', 'email to vendor');
attachment.query();
while (attachment.next()) {
strTemp = attachment.sys_id.toString();
//copy the found attachment to the new data source above.
GlideSysAttachment.copy('sysevent_email_action', strTemp, 'sys_email', current.sys_id);
gs.log('Copy of attcahments for ' + strTemp);
}
This got me to attach the actual document to the email vs the link. Hope this helps. If you have a better way of doing this though, please let me know!
Thank you,
Yeny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2015 10:37 AM
Hello all,
I was able to get this working using a business rule to attach the documents to the email. I hope that this helps other users also who are stuck on the same issue.
First, attach the documents to the notification that will be triggered. Then create a business rule on the sys_email table.
BR
When: Before, Insert
Condition: current.mailbox.getDisplayName() != "Sent" && current.subject == "NEW APPROVED VENDOR EMAIL"
Script:
var strTemp = '';
var attachment = new GlideRecord('sysevent_email_action');
attachment.addQuery('name', 'CONTAINS', 'email to vendor');
attachment.query();
while (attachment.next()) {
strTemp = attachment.sys_id.toString();
//copy the found attachment to the new data source above.
GlideSysAttachment.copy('sysevent_email_action', strTemp, 'sys_email', current.sys_id);
gs.log('Copy of attcahments for ' + strTemp);
}
This got me to attach the actual document to the email vs the link. Hope this helps. If you have a better way of doing this though, please let me know!
Thank you,
Yeny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 10:50 AM
Yeny,
I've tried this script, modified the subject condition to match my email subject, and modified the attachment.addQuery line to find a contain on my attachment name (I assume that is what this does), is there anything else I need to be mindful of changing to get this Business Role working for my specific email, and my attachment on the email notification?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 11:32 AM
Hi Shane,
Make sure that what you are pulling into the query is actually the name of your notification that triggers the email to be sent. attachment.addQuery('name', 'contains', 'notificationName'). For example, my notification's name is "email to vendor- record created" so I have the query looking for a notification that contains 'email to vendor'. Also, make sure that the attachments are attached to the actual notification record and not the source record. This should be all you need for it to work.
Thank you,
Yeny