Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with Email Script

Deepp94
Tera Contributor

Hi Guys,

I am facing issue with an email script.

I have created two buttons Approve and Reject but need some help in removing extra space in between the two and get them aligned.

Adding script here:

(function runMailScript(current, template, email, email_action, event) {

          // Add your code here
    var mark = email.watermark;
 //var emailbody = 'Please provide comments for your approval below this line (optional):';

 var instance = gs.getProperty("instance_name");
    var link = "https://" + instance + ".service-now.com";
        var emailAddress = instance + "@service-now.com";
        var number = current.number;
        var emailbody = email.emailbody,
        response = email.response;

template.print('<span style="color: #ffffff;"><span id="requestapprove" class="btn" style="margin-left: 16px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - approve&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Approve</a>');
//template.print('&nbsp;');
//template.print('<br><br>');

template.print('<span style="color: #ffffff;"><span id="requestreject" class="btn" style="margin-left: 25px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - reject&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Reject</a>');

})(current, template, email, email_action, event);
 
I need to make in below format:
Deepp94_0-1702991149198.png

 

1 ACCEPTED SOLUTION

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Deepp94 ,

I modified your script to show the intended result : 

 

 

(function runMailScript(current, template, email, email_action, event) {

    var mark = email.watermark;

 var instance = gs.getProperty("instance_name");
    var link = "https://" + instance + ".service-now.com";
        var emailAddress = instance + "@service-now.com";
        var number = current.number;
        var emailbody = email.emailbody,
        response = email.response;

template.print('<span style="color: #ffffff;"><span id="requestapprove" class="btn" style="margin-left: 16px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - approve&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Approve</a></span>');


template.print('<span style="color: #ffffff;"><span id="requestreject" class="btn" style="margin-left: 25px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - reject&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Reject</a></span>');

})(current, template, email, email_action, event);

 

 

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Siddhesh

View solution in original post

2 REPLIES 2

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Deepp94 ,

I modified your script to show the intended result : 

 

 

(function runMailScript(current, template, email, email_action, event) {

    var mark = email.watermark;

 var instance = gs.getProperty("instance_name");
    var link = "https://" + instance + ".service-now.com";
        var emailAddress = instance + "@service-now.com";
        var number = current.number;
        var emailbody = email.emailbody,
        response = email.response;

template.print('<span style="color: #ffffff;"><span id="requestapprove" class="btn" style="margin-left: 16px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - approve&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Approve</a></span>');


template.print('<span style="color: #ffffff;"><span id="requestreject" class="btn" style="margin-left: 25px; border-radius: 4px; border: 1px solid #ffffff; padding: 6px 16px; background-color: #4f52bd;">');
template.print('<a href="mailto:'+emailAddress+'?subject=Re:' + current.sysapproval.number +' '+' - reject&body=%0A%0A' + mark + '"style="color:white;font-size:16px;font-weight:bold;"'+link+'"> Reject</a></span>');

})(current, template, email, email_action, event);

 

 

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Siddhesh

Hello @Deepp94 ,

 

Does this resolved you issue ? If yes, It would be great if you mark my response as CORRECT or Helpful so that others can see this on top of the list and get benefited by this.

 

Thanks & Regards,

Siddhesh