Resend email

shaik23
Tera Expert

Hi all,

i am having requirement to resend emails for approvals using ui action 

i have a script i need suggestion 

 

resendThisApproval();
action.setRedirectURL(current.sysapproval)

function resendThisApproval() {
   var e = new GlideRecord("sys_email");
   e.addQuery("type", "sent");
   e.addQuery("target_table", current.getTableName());
   e.addQuery("instance", current.sys_id);
   e.orderByDesc("sys_created_on");
   e.setLimit(1);
   e.query();
 
   if (e.next()) {
      e.mailbox = "outbox";
      e.type = "send-ready";
      if (e.update()) {
         gs.addInfoMessage("Resent: " + e.subject);
      } else {
         gs.addErrorMessage("Could not resend: " + e.subject);
      }
   } else {
      gs.addErrorMessage("Approval email not found for " + current.approver.name + " / " + current.sysapproval.number);
   }
}
1 ACCEPTED SOLUTION

Hi @shaik23 

If your issue has been solved please mark my answer as Accepted Solution.

 

You cant see updated email in email logs because you might be seraching with the wrong query. please open sys_email.LIST and Target as sys_id of the approval record

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

View solution in original post

13 REPLIES 13

type is send-ready and in query you used type should be sent, so it did not find any sent email

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

it worked but i am unable to see updated email in email logs. why ?

Hi @shaik23 

If your issue has been solved please mark my answer as Accepted Solution.

 

You cant see updated email in email logs because you might be seraching with the wrong query. please open sys_email.LIST and Target as sys_id of the approval record

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

@piyushsain i am bit confused can you please provide me a piece of code