- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 06:10 AM
I'm trying to send an email notification to assignment group in incident task record when new/update attachment is added.
Any idea?
"Include Attachments" option sends only on the update in the incident record.
Any help on how to trigger an email notification when attachment alone added?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2016 08:05 PM
Hello Teju,
I have used a similar method for onboarding new users. Here is what I had to do.
I wanted new users on the project to upload required security documents. Once they uploaded documents, based on the conditions that their attachments that were uploaded to their profile contained the key words "HIPAA" and "DHS" would trigger an event (notice the event name that is created is "onboard.attachment").
off the event, an email notification and template would be shot out.
BR - User Form Attach Notify
var userrec = new GlideRecord("sys_user");
userrec.get(current.table_sys_id);
var today = new GlideDate;
var pattern = "HIPAA";
var result = current.file_name.match(pattern);
if (JSUtil.has(result) ) {
gs.log("filename " + current.file_name + " for user " + userrec.name + " contains " + pattern);
gs.eventQueue('onboard.attachment', current, gs.getUserDisplayName(), userrec.name);
}
else {
pattern = "DHS";
result = current.file_name.match(pattern);
if (JSUtil.has(result) ) {
gs.log("filename " + current.file_name + " for user " + userrec.name + " contains " + pattern);
gs.eventQueue('onboard.attachment', current, gs.getUserDisplayName(), userrec.name);
}
else gs.log("filename " + current.file_name + " for user " + userrec.name + " not matched to a pattern");
}
//gs.log("user " + userrec.name);
//if (userrec.sys_created_on > gs.daysAgo(30)) {
// gs.log(" new user " + userrec.name + ", created " + userrec.sys_created_on + " just attached file " + current.file_name );
//Queue the email send event
//Pass in event name, record(not applicable here), custom parm1, and custom parm2
//Custom parm1 is the count of incidents queried and can be referenced from the email notification that responds to the queued event by using '${event.parm1}' in the email notification record.
//gs.eventQueue('onboard.attachment', current, gs.getUserDisplayName(), userrec.name);
//gs.getUserName()
//}
//else gs.log(" old user attachment, created " + userrec.sys_created_on + " just attached file " + current.file_name );
The Email Notification that fires off the event named "onboard.attachment" and the email template associated with the email notification.
Now based on your request you were wanting to apply a similar situation to an incident. simply change the code that references the "sys_user" table in the GlideRecord to the incident table and the file names that are being searched for. You could also look at this old code we have when we were not searching attachments based on file names.
var userrec = new GlideRecord("sys_user");
- userrec.get(current.table_sys_id);
var today = new GlideDate;
- gs.log("user " + userrec.name);
if (userrec.sys_created_on > gs.daysAgo(14)) {
gs.log(" new user " + userrec.name + ", created " + userrec.sys_created_on + " just attached file " + current.file_name );
//Queue the email send event
//Pass in event name, record(not applicable here), custom parm1, and custom parm2
//Custom parm1 is the count of incidents queried and can be referenced from the email notification that responds to the queued event by using '${event.parm1}' in the email notification record.
- gs.eventQueue('onboard.attachment', current, gs.getUserDisplayName(), userrec.name);
//gs.getUserName()
}
else gs.log(" old user attachment, created " + userrec.sys_created_on + " just attached file " + current.file_name );
I hope this helps. Please let me know should you have any questions.
Sincerely,
Orlando Galindo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 09:06 PM
Anyone has idea on this ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2016 10:18 AM
If you are doing the one that triggers off the sys_attachment table, since you are on that record, you can try to add a link to the attachment:
https:// your_instance.service-now.com/nav_to.do?uri=sys_attachment.do?sys_id=80572e364f1d9ac02ce6fd511310c762
if you have the sys_id you can also do as it says here: Email Notifications - ServiceNow Wiki
7 Attaching Documents to a Notification
You can include all attachments from the source record with the notification. For example, if an incident update generates a notification, you can include all attachments from the incident record with the notification. To include all attachments from the source record, select the check box for the Include attachments field. Note that email messages, including attachments, cannot exceed the maximum email size or email attachment limits. This size includes MIME encoding, which increases total attachment size by approximately 37%.
7.1 Attaching Documents with Scripting
Using scripting, you can attach documents by linking to them, or you can attach various types of reports by specifying their IDs in the system.
7.2 Linking to an Attachment
You can add attachments to a notification by linking to the attachment record in the message of the notification. Linking to attachment records in this fashion requires using email notification scripting. For example:
template.print('Attachment: <a href="/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>\n');
If you are doing it through the attachment uploaded you will need to review those.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 07:47 AM
My 50 Cents (this is not the nice solution, but it does the trick when the attachment event was not yet available).
We added automatically a worknotes to the record when an attachment is added or removed. Then the worknotes notification was doing the rest. But of course, this is now probably best to do it the way William explained you.
BR
Marc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 07:52 AM
Hi March, BUT the sol is not working it is not triggering a notification.
I simply added a condition "Assignment group is not empty" and "Event is Fired" , Event name as "attachment.uploaded" .
Added a test as subject in What it will contain tab
Still i dont see any notification triggers.
When i check the Registry for attachment.uploaded table name seems to be empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 08:43 AM
Can you please tell me how did you manage to setup a condition for worknotes when an attachment is added or removed??Can you provide me the sample of it. I checked thro' UI policy we cannot get relevant fields..