Inbound Email Action:Attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2009 03:53 PM
I have created an inbound email rule that will search any subject or email body for an incident number, and update the ticket accordingly. If it does not find an existing incident, it creates a new one. This functionality works whether a watermark is on the message or not.
When these emails have attachments, the new incidents that are created get the attachment just fine, but the incidents that are updates are not getting the attachments on the mail.
Anyone have any ideas what I am missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2009 09:56 AM
The attachment is there but most likely on the sys_email record.
Check and see if that record has your attachment. If so then you might be able to use something like this to move your attachments from the sys_email to the existing incident record.
Packages.com.glide.ui.SysAttachment.copy('sys_email',gl.sys_email.u_sys_email,'incident',gl.incident.u_incident);
You will need to know the sys_id for both the sys_email record and the existing incident record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2009 10:30 PM
Hi All
I found the way to copy attachments using "Inbound Action".
I could not use the property email.sys_id of the email record (sys_email table) but it is possible to use email.uid property (Wiki: http://wiki.service-now.com/index.php?title=Email_Record_Fields Uid comes from the email server and is the value that uniquely identifies each email. We get that value from the email server and put it into this field.). Since email.uid uniquely identifies an email in sys_email table we can use the following script in our inbound action:
My "Inbound Action":
... some code that finds sys_id of incident to be updated and puts it in requestId variable
// The problem was that I was not able to use email.sys_id property (it is not defined). So I'm using email.uid propery.
...
updateEmailAndCopyAttachments(email.uid, 'incident', requestId);
...
// Copy attachments from email to target table, sligtly modified compared to above.
function updateEmailAndCopyAttachments(emailuid, destTable, destId) {
var em = new GlideRecord('sys_email');
// the key difference from above mentioned function is that I'm querying by uid and not by sys_id!
em.addQuery('uid', emailuid);
em.query();
if(em.next()) {
var emailId = em.sys_id;
// it is important to update email record in sys_email table with the task that email belongs to in order to be able to see that email in task Activity (if you show there received and sent emails)
em.instance = destId;
em.update();
Packages.com.glide.ui.SysAttachment.copy ('sys_email', emailId, destTable, destId);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2010 06:46 AM
I found this and was using it and thought I would post a note on an improvment.
If you add
em.target_table = destTable;
before the
em.update();
you will have the email records instance field show the record that you created, assuming you are creating just one record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2010 09:47 AM
would you mind sharing the inbound email action that "will search any subject or email body for an incident number, and update the ticket accordingly. If it does not find an existing incident, it creates a new one. This functionality works whether a watermark is on the message or not."
Thanks in advance