Resend Button in E-Mail Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 11:06 AM
In an Event triggered E-Mail Notification(named "Approval Cost Center"), I need to add a button called "Resend" and when the button is clicked, the same mail should send again.
What I did:-
I added a E-Mail Notification Script, I added the following code
template.print('<table style="height: 51px;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0" width="506"><tbody><tr align="center"><td align="center"><a href ="' + gs.eventQueue("costCenterApproval", current, gs.getUserID(),current.sysapproval.request.requested_for) + '"><img src="https://' + gs.getProperty('instance_name') + '.service-now.com/email.png" alt="Resend-Button" width="150" height="25"/></a>.</td></tr></tbody></table>');
Here "costCenterApproval" is the name of the Event, which triggers the Notification("Approval Cost Center"). It's not working. Actually the E-Mail Notification is triggering multiple items.
My question is "Is it a better approach?. if yes, where I am going wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 04:49 PM
Hi, perhaps you could start with clear details of your business requirement\intended solution as your post is not clear and looking at your code you appear to be trying to trigger a sysEvent from a sent email message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2022 11:20 PM
I want to add a button in my E-Mail Notification. When this button is clicked, the particular E-Mail should be resend again. What I did:-
In the Notification, I added this E-Mail Script. At the beginning, I added an Event(which triggers this Notification) in the E-Mail script as I mentioned in my First post. But the problem, it was triggering multiple times and also it is even triggered without Button Click function.
So now I changed this E-Mail script as follows. It is an OOB script. I find that particular E-mail in the sys_email table with the sys ID and trying to resend it. But this also doesn 't work. Hope I have explained you better. If not , I can write it agian
var urlEmail = 'https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=%2Fsys_email.do%3Fsys_id%3D' + emailSysID + '%26sysparm_record_target%3Dsys_email%26sysparm_record_row%3D1%26sysparm_record_rows%3D1%26sysparm_record_list%3Dsys_id%253D' + emailSysID + '%255EORDERBYDESCsys_created_on';
var linkResend = '<p><a target="_blank" href="' + urlEmail + '">Resend Email</a></p><br>';
var grResendEmail = new GlideRecord('sys_email');
grResendEmail.addEncodedQuery("sys_id",emailSysID);
grResendEmail.query();
while (grResendEmail.next()) {
grResendEmail.type = "send-ready"; // this is the first update
grResendEmail.update();
grResendEmail.mailbox = "outbox"; // note this happen as a second update
grResendEmail.state = "ready";
grResendEmail.update();
}
template.print(linkResend);
I just included this E-Mail script in my Notification. Hope you will give me some suggestions to Proceed.