- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 06:10 AM
Hi Community,
I have created this email script and Script Include. Instead of image I want text "Click here to Accept", "Click here to Reject". and I have added some changes but it is not working.
Can anyone suggest me where I have to make changes ?
var img = "/Accept.png";
var response = "accept";
var emailbod = "I accept this request.";
template.print(ApprovalRejectObject(img, response, emailbod));
and script Include,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 02:53 AM
Hi @Harsha1 ,
Hope you are doing great.
In the email script, you mentioned that instead of an image, you want to include the text "Click here to Accept" and "Click here to Reject." To achieve this, you need to replace the code for the image with the respective text. Please tru using below reference script:
var response = "accept";
var emailbod = "I accept this request.";
var acceptText = '<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod + mark + '">Click here to Accept</a>';
response = "reject";
emailbod = "I reject this request.";
var rejectText = '<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod + mark + '">Click here to Reject</a>';
template.print(acceptText + " | " + rejectText);
Regards,
Riya Verma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 06:35 AM
@Harsha1 I have ServiceNow YouTube videos how to use both buttons (Approval or Reject) in an email notification for your reference.
https://www.youtube.com/watch?v=70tyNbYUjpc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 12:16 AM
Hello @Harsha1
I have used only Email script for Approve and Reject Buttons.
Please find below script for your reference :
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
//OOB system property to guide to uri and to the case
var linktoCase = gs.getProperty('glide.servlet.uri') + "/esc?id=hrm_ticket_page&table=" + '${hr_service.topic_detail.topic_category.coe}' + "&sys_id=" + '${sys_id}';
//Email for instance
var Email = gs.getProperty("sn_hr_core.hr_email").substring(16).slice(0, -1);
//email link
var EmailLink = '<a style="color:#001EFF;text-decoration: none;"href=mailto:"' + Email + '">' + Email + '</a>';
/************************************************************************
/* Button Section Approve Completion and Reject Completion buttons
/* that load an email respectively
/***********************************************************************/
var approvalbuttonText = gs.getMessage('Accept');
var rejectbuttonText = gs.getMessage('Reject');
//Accept Completion Button
var watermark = email.watermark; //Body of email that has the watermark for the user that is approving
var Approvehref = "mailto:" + Email + "?subject=Re:${number}%20-%20Accept%20%20Completion&body=" + watermark;
var ApproveAnchor = Approvehref;
ActiveButtonHyperlink = ApproveAnchor;
/*********************************************
Newly added to display a link for accept. Comment out the lines in this section when adding buttons back.
*********************************************/
var AccepthrefLink = '<a href=' + '"mailto:' + Email + "?subject=Re:${number}%20-%20Accept%20%20Completion&body=" + watermark + '">' + approvalbuttonText + '</a>';
template.print(AccepthrefLink);
template.print(' ');
/*end of newly added to display a link*/
//Reject Completion Button
var Rejecthref = '<a href=' + '"mailto:' + Email + "?subject=Re:${number}%20-%20Reject%20%20Completion&body=" + watermark + '">' + rejectbuttonText + '</a>';
template.print(Rejecthref);
template.print('<br></br>');
})(current, template, email, email_action, event);
Please mark my answer helpful and accept the solution.
Thank you.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 02:53 AM
Hi @Harsha1 ,
Hope you are doing great.
In the email script, you mentioned that instead of an image, you want to include the text "Click here to Accept" and "Click here to Reject." To achieve this, you need to replace the code for the image with the respective text. Please tru using below reference script:
var response = "accept";
var emailbod = "I accept this request.";
var acceptText = '<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod + mark + '">Click here to Accept</a>';
response = "reject";
emailbod = "I reject this request.";
var rejectText = '<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod + mark + '">Click here to Reject</a>';
template.print(acceptText + " | " + rejectText);
Regards,
Riya Verma