In email body ,when clicked the approve button its not working for STD

Preksha Kapoor
Tera Contributor

Hi Folks,

 

We have an email approval button which is being used for all the kind of approval tasks notifications, so if the approver wants they can approve the particular task by clicking on that button and it will give a new email with the subject RE: approve CHGxxxxxx along with the reference message id.

 

However, it is not working for the Standard change Proposal tickets as when we are clicking on the button it takes us to the new mail with subject "RE: approve undefined", instead of putting the STDxxxxxx number.

Note: the notification for proposal is being configured on the Standard change proposal table

 

Below is the email script we are using :

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
   
    var subjectTxt = encodeURI('RE: approve ' + current.sysapproval.number);
   
    var bodyTxt = " " + "%0D%0A" +
    "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" + "%0D%0A" +
    "%0D%0A" + "%0D%0A"; // Blank space for comments

    // Divider line with instructions
    bodyTxt += "%0D%0A" + "_____________________________________________________________________________________";
    bodyTxt += "%0D%0A" + "**Please provide any additional comments or feedback in the section above the line.**";

    // Asterisk separator before the watermark with instruction
    bodyTxt += "%0D%0A" + "*******************************************";
    bodyTxt += "%0D%0A" + "**Please do not change the items below the line.**";
   
    // Adding watermark
    bodyTxt += "%0D%0A" + email.watermark;
    bodyTxt += "%0D%0A" + "*******************************************";
   
    template.print('<a title="click here" href="mailto:arnottstest@service-now.com?SUBJECT=' + subjectTxt + '&amp;body=' + bodyTxt + '"><img src="approve3.png" width="123" height="32"/></a>');
    template.print(answer);

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

 

 

 

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @Preksha Kapoor 

Firstly, you should configure your notification in the Approval (sysapprover_approval) table, not in the Standard Change Proposal table.
If you make this change, your email script will work as expected.

The reason it's currently showing "undefined" instead of the Standard Proposal number is because the notification record is configured in the Standard Change Proposal table. As a result, the current object refers to the Standard Change Proposal record, not the approval record. So, try the below script and see..

var subjectTxt = encodeURI('RE: approve ' + current.number);

Regards
Siva

View solution in original post

1 REPLY 1

J Siva
Tera Sage

Hi @Preksha Kapoor 

Firstly, you should configure your notification in the Approval (sysapprover_approval) table, not in the Standard Change Proposal table.
If you make this change, your email script will work as expected.

The reason it's currently showing "undefined" instead of the Standard Proposal number is because the notification record is configured in the Standard Change Proposal table. As a result, the current object refers to the Standard Change Proposal record, not the approval record. So, try the below script and see..

var subjectTxt = encodeURI('RE: approve ' + current.number);

Regards
Siva