For incoming emails - how do you set the target?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 10:41 AM
I am not using a watermark to update an incoming email - I'm actually going through a glide query and updating it that way.
Because of this, the target is empty (even though the email is updating the record). This causes all the attachments on the email to NOT get copied over to the record.
How do I set the current email target to the glide query record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 11:52 AM
You can set the email target using
sys_email.target_table = 'table_name';
sys_email.instance = [object];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 05:47 PM
There are several mechanisms for determining whether an incoming email is a reply and what it is a reply to. Watermark and subject line can both be used (though watermark is most reliable).
If you are not using either of these mechanisms and your only concern is the attachments, it shouldn't be all that difficult to do. Attachments should be associated to the sys_email you are working on, so you'll be querying the sys_attachment table where the "table_name" is "sys_email" and the "table_sys_id" is "email.getUniqueValue()". Then you'd set those same values to the target table and record instead.
That would look something like:
var attachments = new GlideRecord('sys_attachment');
attachments.addQuery('table_name', 'sys_email');
attachments.addQuery('table_sys_id', sys_email.getUniqueValue());
attachments.query();
while (attachments.next()) {
attachments.setValue('table_name', target.getTableName());
attachments.setValue('table_sys_id', target.getUniqueValue());
attachments.update();
}
Update: I've tested this and it worked for me.