Notification script problem

avinashdubey103
Tera Guru

Hi I have written the below script :

Instead of giving clickable link that open mails it is printing that text :

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



    var softwareURL = '';

    var pricePerMonth = '';

    var duration = '';

    var totalAmount = '';

    var businessNeed = '';



    var grRitm = new GlideRecord('sc_req_item');

    grRitm.addQuery('number', current.sysapproval.getDisplayValue());

    grRitm.query();



    if (grRitm.next()) {

        softwareURL = grRitm.variables.u_software_service.getDisplayValue();

        pricePerMonth = grRitm.variables.u_price.getDisplayValue();

        duration = grRitm.variables.u_duration.getDisplayValue();

        totalAmount = grRitm.variables.u_total_amount.getDisplayValue();

        businessNeed = grRitm.variables.u_business_needs.getDisplayValue();

    }



    var approverName = current.approver.getDisplayValue();



    var emailBody = "<p>Dear " + approverName + ",</p>" +

                    "<p>On " + current.sysapproval.sys_created_on.getDisplayValue() + ", your employee " + current.sysapproval.task_for.getDisplayValue() + " submitted the following Request:</p>" +

                    "<p><a href='/sc_req_item.do?sys_id=" + current.sysapproval.getUniqueValue() + "'>" + current.sysapproval.number + "</a> – Request new GenAI software.</p>" +

                    "<p>Software name: " + softwareURL + "</p>" +
                    "<p>Business needs: " + businessNeed + "</p>" +
                    "<p>Usage period: " + duration + "</p>" +
                    "<p>Software monthly cost: " + pricePerMonth + "</p>" +
                    "<p>Software total cost: " + totalAmount + "</p>" +

                    "<p>If you choose to approve the purchase of this software, " + current.sysapproval.task_for.getDisplayValue() + " (" + current.sysapproval.task_for.user_name+ ") will be able to go ahead and order it directly from the vendor, and then submit the receipts for reimbursement via the My Expense portal. The cost of the subscription will be loaded into " + current.sysapproval.task_for.getDisplayValue() + "'s Profit Center / division.</p>" +

                   
                    "<p>Please approve or reject/decline the request.</p>" +

                    "<div><label style='color: #324450;'> ${mailto:mailto.approval.accept}</label>&nbsp;&nbsp;&nbsp;&nbsp;<label style='color: #324450;'>${mailto:mailto.rejection.accept}</label></div>" +


                    "<p>Regards,</p>" +

                    "<p><b>Amdocs IT</b></p>";



    email.setSubject("A request for GenAI software is pending your approval");

    email.setBody(emailBody);

    email.setContentType("text/html");

    email.send();



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

Screen shot:


avinashdubey103_0-1703666957134.png

 

8 REPLIES 8

Hi ,

 

When  I am trying to construct the using a tag :

                     "<div><a href="'+${mailto:mailto.approval.accept} +'">Accept </a> </div>"+
 
it is giving syntax error

Hi @avinashdubey103 

 

try 

"<div><a href="+${mailto:mailto.approval.accept} +">Accept </a> </div>"+

 

PS: I have removed extra quotes

vipinmathew
Mega Guru

Hi @avinashdubey103  ,

 

Just try replacing this line of code 

"<div><label style='color: #324450;'> ${mailto:mailto.approval.accept}</label>&nbsp;&nbsp;&nbsp;&nbsp;<label style='color: #324450;'>${mailto:mailto.rejection.accept}</label></div>" 

 

WITH below code 

"<div><label style='color: #324450;'>"+ ${mailto:mailto.approval.accept}+"</label>&nbsp;&nbsp;&nbsp;&nbsp;<label style='color: #324450;'>"+${mailto:mailto.rejection.accept}+"</label></div>" 

 

Please let me know if this works for you or not. 

Happy to help 🙂

 

Thanks 

Vipin Mathew

Sajid Sheikh
Tera Contributor

Hello Avinash,
Please update when you have a solution.