Approve/Reject Button in a Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2019 08:05 PM
Hello,
I have a requirement to configure Approve and Reject button in an email notification for Change. What is the best process to have this configured on the email notification instead of having a text for approve/reject?
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2019 09:17 PM
Via HTML you can make button.
Refer below code it will make a button
<table style="text-align: center; background-color: #82c9b8; border-color: #82C9B8; border-radius: 5px; color: white; height: 35px;">
<tbody>
<tr>
<td style="text-align: center; color: #ffffff; padding-left: 20px; padding-right: 20px; font-size: 16px;">LINK TO Approvae</td>
</tr>
</tbody>
</table>
</td>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2019 01:38 AM
Hi Tim,
You need to write a script include & mail script that will achieve what is required as below.
Script include:renderMailToButton
function renderMailtoButton(image, response, emailbod){
var instance = gs.getProperty("instance_name");
var link = "https://" + instance + ".service-now.com";
var mark = email.watermark;
var number = current.number;
//gs.log('Number is ',number);
var number1=current.week_starts_on;
//gs.log('Number1 is',number1);
var emailAddress = instance + "@service-now.com";
//Different number if from an approval
if (current.getTableName().indexOf("sysapproval") != -1){
number = current.sysapproval.number;
//gs.log('Number r',number);
}
var mailLink = '<a href="mailto:'+ emailAddress + '?subject=Re:' + number + ' ' + response +'&body=' + emailbod + mark + '"><img src="' + link + image + '"></a>';
return mailLink;
}
For Approve
Mail Script: email.approve.button.insert
var img = "/approve.png"; //considering approve.png is the image stored in Image table of ServiceNow
var response = "approve";
var emailbod = "I approve this request.%0D%0A%0D%0A";
template.print(renderMailtoButton(img, response, emailbod));
For Reject
Mail Script: email.reject.button.insert
var img = "/reject.png"; //considering reject.png is the image stored in Image table of ServiceNow
var response = "reject";
var emailbod = "I reject this request.%0D%0A%0D%0A";
template.print(renderMailtoButton(img, response, emailbod));
Once done you need to call the above mail scripts in below format in email notification body
${mail_script:email.approve.button.insert} ${mail_script:email.reject.button.insert}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2019 05:25 AM
I will try this. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2019 09:21 AM
It is not working. What could be the issue?
I created the Script include and email scripts but it is not populating in the notification.
var renderMailToButton = Class.create();
renderMailToButton.prototype = {
initialize: function() {
},
type: 'renderMailToButton'
};
function renderMailtoButton(image, response, emailbod){
var instance = gs.getProperty("instance_name");
var link = "https://" + instance + ".service-now.com";
var mark = email.watermark;
var number = current.number;
//gs.log('Number is ',number);
var number1=current.week_starts_on;
//gs.log('Number1 is',number1);
var emailAddress = instance + "@service-now.com";
//Different number if from an approval
if (current.getTableName().indexOf("sysapproval") != -1){
number = current.sysapproval.number;
//gs.log('Number r',number);
}
var mailLink = '<a href="mailto:'+ emailAddress + '?subject=Re:' + number + ' ' + response +'&body=' + emailbod + mark + '"><img src="' + link + image + '"></a>';
return mailLink;
}
Thanks for your help.
