How to get all attachments from email received using inbound action

Evren Yamin
Tera Contributor

If the instance received an email with attachments.

How could I include the attachments in the created task using inbound action?

Appreciate all the help.

Thank you.

1 ACCEPTED SOLUTION

Hi @Evren Yamin ,

I think what is happening is your attachments are getting picked up by some other pre-defined OOTB inbound action, most probably "Create Incident". Can you go to the Inbound Actions list from the application navigator, and deactivate the Create Incident action, and then try?

Also, like i've mentioned above, you don't have to query the attachments explicitly and then associate it to the task, if you're doing current.insert/current.update already in your inbound action to create/update a task.

 

Thanks & Regards,

Rishabh Jha

Aavenir(http://www.aavenir.com/)

View solution in original post

9 REPLIES 9

Hi Even,

You can update the new task sysid  and task table name.

you jst need to replace the table name and sysid in the below script.

Replace the highlighted column with the created task sysyidand tabel name.

var sysAttach = new GlideSysAttachment();   
var emailSysId = sys_email.getUniqueValue(); 
gs.log("Email sys_id is: " + emailSysId, "TITUS");
if (emailSysId) { 
   var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId); 
   while (sysEmailAttachments.next()) { 
         sysEmailAttachments.setValue("table_name", "tasktable"); // table name
         sysEmailAttachments.setValue("table_sys_id", current.getUniqueValue()); //new task sysid
        
   } 


} 

 

If not working then can you please give more details what you are doing in the inbound actions.

Please mark helpful and correct.

Thanks,

CB

 

Hi CB,

I'm using that code and I was able to create a task after receiving an email but it does not include the attachments.

Here is the code.

var sysAttach = new GlideSysAttachment();
var emailSysId = sys_email.getUniqueValue();
gs.log("Email sys_id is: " + emailSysId, "TITUS");
if (emailSysId) {
var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId);
while (sysEmailAttachments.next()) {
sysEmailAttachments.setValue("sc_task", "tasktable"); // table name
sysEmailAttachments.setValue("5e542ffe2ff0101056198d1df699b6f7", current.getUniqueValue()); //new task sysid
}
}
current.description = email.body_text;
current.short_description = email.subject.toString();
current.state = 3;
current.assignment_group.setDisplayValue("Service Desk");
current.insert();

event.state = "stop_processing";

Hi @Evren Yamin ,

I think what is happening is your attachments are getting picked up by some other pre-defined OOTB inbound action, most probably "Create Incident". Can you go to the Inbound Actions list from the application navigator, and deactivate the Create Incident action, and then try?

Also, like i've mentioned above, you don't have to query the attachments explicitly and then associate it to the task, if you're doing current.insert/current.update already in your inbound action to create/update a task.

 

Thanks & Regards,

Rishabh Jha

Aavenir(http://www.aavenir.com/)

Hi @Rishabh Jha - Aavenir,

Thanks for this input.

It's working now.

 

I'm glad that it helped solving your issue!

 

Thanks & Regards,

Rishabh Jha

Aavenir(http://www.aavenir.com/)