Email attachment not getting attached with inbound action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 05:19 PM
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();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 10:42 PM
Hi Sam
Can you check the logs once and see if the control is entering into that 2nd if condition.
gs.include('validators');
var grEmailWatermark = new GlideRecord('sys_watermark');
grEmailWatermark.addQuery("number", email.body.ref);
grEmailWatermark.query();
if (grEmailWatermark.next()) {
gs.log("Entered into 1st if condition");
var vSourceID = grEmailWatermark.source_id;
var grSctask = new GlideRecord('sc_task');
grSctask.addQuery("sys_id", vSourceID);
grSctask.query();
if (grSctask.next()) {
gs.log("Entered into the 2nd "
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 10:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 10:54 PM
Okay, i added the sys_id log.. can you check the output of current.sys_id
Then go to sys_attachment.list and filter by table_sys_id with the value of current.sys_id and check if your find your attachment or not there.
gs.include('validators');
var grEmailWatermark = new GlideRecord('sys_watermark');
grEmailWatermark.addQuery("number", email.body.ref);
grEmailWatermark.query();
if (grEmailWatermark.next()) {
gs.log("Entered into 1st if condition");
var vSourceID = grEmailWatermark.source_id;
var grSctask = new GlideRecord('sc_task');
grSctask.addQuery("sys_id", vSourceID);
grSctask.query();
if (grSctask.next()) {
gs.log("Entered into the 2nd "+current.sys_id+"---taskid: "+grSctask.sys_id);
grSctask.work_notes = "Forward from: " + email.origemail + "\n\n" + email.body_text;
GlideSysAttachment.copy("sys_email", current.sys_id, 'sc_task', grSctask.sys_id);
grSctask.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 11:17 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 11:40 PM
Okay,
Try like this and check now if the sys_id is coming correctly now.
gs.include('validators');
var grEmailWatermark = new GlideRecord('sys_watermark');
grEmailWatermark.addQuery("number", email.body.ref);
grEmailWatermark.query();
if (grEmailWatermark.next()) {
gs.log("Entered into 1st if condition");
var vSourceID = grEmailWatermark.source_id;
var grSctask = new GlideRecord('sc_task');
grSctask.addQuery("sys_id", vSourceID);
grSctask.query();
if (grSctask.next()) {
gs.log("Entered into the 2nd "+vSourceID+"---taskid: "+grSctask.sys_id);
grSctask.work_notes = "Forward from: " + email.origemail + "\n\n" + email.body_text;
GlideSysAttachment.copy("sys_email", vSourceID, 'sc_task', grSctask.sys_id);
grSctask.update();
}
}