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

Sandeep Rajput
Tera Patron
Tera Patron

@shaik23 Instead of querying the sys_email table, can't you re-trigger the email using gs.eventQueue('event_name',current,'param1','param2'); ?

@Sandeep Rajput  It is recommended method ?

Yes, after all events are used for triggering emails.

piyushsain
Tera Guru
Tera Guru

Hi @shaik23 

By looking at your script the code will just pull any email that is on the table, it can be another email which is not for approval. If the current table is approval table then it works but other than that you need to add more query to find correct email.

I will suggest you to create a new copy of the email as it will be logged in the system that the email is sent multiple times or you can use event queue to trigger another email

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