how to create a button in an email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2018 07:58 AM
suggest me step by step of how to create a approve button in an email.
thanks in advance
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2018 08:05 AM
Hi,
Store the Approve and Reject images in the Images Module.
Create one Notification email script and add below code:
var img = "/approve.png"; //Path of image
var response = "approve";
var emailbod = "I approve this request.";
template.print(renderMailtoButton(img, response, emailbod));
Add the above email script under Approval Notification:
${mail_script:email.approve.button.insert}
Hope this will help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 08:18 AM
Hello Shashikant
Im having some issues displaying the body in the approval reply, my mail script matches yours. Would there by anything else preventing it?
The URL is:
mailto:XXXXXXXXXXX@service-now.com?subject=%20Re:RITM0034100%20-%20approve&body=%0A%0ARef:MSG0390932
Many thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 08:27 AM
Ugggg, dont mind me...I found the script include
...not enough coffee today

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 11:51 AM
Hi sudha,
Try this,
Below are portions of a script include I wrote that was called from mail scripts to print the html. I found this approach easier to manage and re-use. You can essentially drop these in a script include and call them from a mail script via a call like
template.print(new myUtil().getButton('https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri='+tbl+'.do?sys_id='+GlideRec.getValue('sys_id')+'', btnName, 'View the record' ));
//specify the link (ie https://mylink.com), the text (Button Text), and the tool tip or title text
getButton:function(link,text,title){
return '<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
'<tr><td><table border="0" cellspacing="0" cellpadding="0"><tr>'+
'<td align="center" style="-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" bgcolor="#37424A">'+
'<a title="'+title+'" href="'+link+'" target="_blank" '+
'style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; '+
'-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; padding: 12px 18px; border: 1px solid #222222; display: '+
'inline-block;"><strong style="font-weight:normal;">'+text+'</strong></a></td>'+
'</tr></table></td></tr></table>';
},
Button this code generates: