Email attachment not getting attached with inbound action

Sam198
Mega Guru

Hi all,

I have an inbound action where it was initially sent from the ticket but the receiver fwd it back to us, the below inbound action picks that up and adds it to the initial ticket, however the attachment is not getting attach, i am using the GlideSysAttachment.copy function but it does not attach the attachment.

 

gs.include('validators');

var grEmailWatermark = new GlideRecord('sys_watermark');
grEmailWatermark.addQuery("number", email.body.ref);
grEmailWatermark.query();

if (grEmailWatermark.next()) {
var vSourceID = grEmailWatermark.source_id;
var grSctask = new GlideRecord('sc_task');
grSctask.addQuery("sys_id", vSourceID);
grSctask.query();

if (grSctask.next()) {
grSctask.work_notes = "Forward from: " + email.origemail + "\n\n" + email.body_text;
GlideSysAttachment.copy("sys_email", current.sys_id, current.target_table, current.instance);

grSctask.update();
}
}

11 REPLIES 11

MrMuhammad
Giga Sage

Hi,

It should have attached automatically without explicitly using GlideSysAttachment.copy as you are attaching attachment on the target record that got updated by inbound action. Have you tried without that? 

If that doesn't work then update as below

GlideSysAttachment.copy("sys_email", current.sys_id, "sc_task", gr.getValue("sys_id"));

Thanks & Regards,

Sharjeel

 

Regards,
Muhammad

Hi Muhammad,

No its not attaching automatically, that's what i was thinking but it did not so i have to now look at the solution. I added the updated line that you provided - that did not add the attachment too.

Hi Sam,

Have you placed any logs? Where the code is broken? 

I think current.sys_id must be replaced with current.table_sys_id

GlideSysAttachment.copy("sys_email", current.table_sys_id, 'sc_task', grSctask.sys_id);

Let me if you face any issues. 

Thanks,

Sharjeel

Regards,
Muhammad

Sajilal
Mega Sage

Ideally it automatically does this, can you please check in email logs if the attachment is being recieved from the end user.

Also is the record being inserted? Also by any chance any edit ACL access on the attachment table to the user or the record itself, check this too once.

I suggest to raise a Ticket to Hi then implement the customization of copying the attachments as suggested by our expert Muhammad above.

Thanks,

Saji