The CreatorCon Call for Content is officially open! Get started here.

how add a button in email notification

samadam
Kilo Sage

I am trying to send email when an approval is inserted for a non task table in a scoped app, I created a notification. How can I add a button to say "Agree to the conditions" which would work like approval and update approval state on the record?

 

Thanks

7 REPLIES 7

Harshal Aditya
Mega Sage

Hi,

I think you need to update email notification body to include a button.

You may try adding <button href="mailto:mailto.approval">Approve</button>

Regards

Harshal

Megha Dubhashi
Kilo Guru

Hi samadam,

Check the link. you may get any help from this.

https://community.servicenow.com/community?id=community_question&sys_id=0836549a1b4100107a5933f2cd4bcbe1

 

Regards,

Megha

Ujjawal Vishnoi
Mega Sage

Hi @samadam 

Please follow below steps

1) Create an email notification script as below.

var link = gs.getProperty("instance_name") + "@service-now.com";
var mailLink = "mailto:" + link + "?subject=Re:Yes&body="+email.watermark;
template.print("<a href="+mailLink + ">Agree to the conditions</a>");

 

2) Use this email script in your notification created on sysapproval_approver table with condition as source table is your custom table

find_real_file.png

Add the email script in Message HTML field as below.

${mail_script:nameOfEmailScript}

 

3)Create a reply type of inbound email action as below

find_real_file.png

 

Use script as below.

var tableName = "yourCustomTableName";

if ( email.subject == "Re:Yes") {
current.state = "approved";
current.update();
}
var gr = new GlideRecord(tableName);
gr.get(current.document_id);
gr.u_state = "Approved";
gr.update();

 

Hope this helps.

 

Regards,

Ujjawal

Hi @samadam

If I helped you to resolve your query with my answer. Then I would really appreciate if you can mark my answer correct and helpful. So that it can be moved to answered list and helpful for future readers.

Regards,
Ujjawal