How can I copy the email sent/received from the activity log on the RITM to the sctask

Cindyco
Tera Contributor

I have read all of the posts I could find where this is asked but have not seen any answers.  When someone replies to an email it is attached to the RITM activity log as email received.  I would like to know how to copy this to the sctask activity log?

Has anyone had any success doing this?

Thanks in advance

10 REPLIES 10

Tony Chatfield1
Kilo Patron

Hi, the 'email' visible on your RITM record activity filter is the received email message. This message cannot be made visible from 2 different record activity filters\task views within the instance and creating 'fake' duplicate email messages would not be a best practice solution for your requirement.
As an alternative, during processing of the inbound message you could update your inbound action to copy key message details into the comments or work_notes journal of any child task. 

Hi Tony,

Thanks for the reply.  Are you saying that in the inbound action called "update requested item" I can add something for the sc_task table?  Would it work to just copy below and change the table name?

Here is the current script

if (current.getTableName() == "sc_req_item" && current.canWrite()) {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;
}
current.update();

Hi @Cindyco 

You can use same inbound action script to update comments of task with email body

if (current.getTableName() == "sc_req_item" && current.canWrite()) {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;
}
current.update();

//This part can be used to copy same email content to sc_task

var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',current.sys_id);
grTask.query();
while(grTask.next()){
grTask.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
grTask.update();
}
//end of task updation

 

I have added the task comments update logic at last, you can adjust thar part in your inbound action script.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Thanks for this I tried it and even changed request_item to sc_req_item and it did not add anything to the sc_task.  Anything else you can think of?