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.

Notification content issue regarding URL configuration

Are Kaveri
Tera Contributor

Hi 

 

I have configured one email notification on Approval(sys_approval) table.

for my notification content i need to include the request(custom request table) URL in my body of email notification.

 

since it need to navigate to portal page. I have written an email script and called the mail script in the notification.

 

when email is triggered the request URL link was labeled as undefined.

 

Please help me.

I have called my mail script in body html(${mail_script:req_details})

email script:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    var reqNum;
    var uniqueID = current.getUniqueValue();
    var req = new GlideRecord('my_request_table');
    req.addQuery('sys_id', uniqueID);
    req.query();
    if (req.next()) {
        reqNum = req.number + '';
    }

    var url = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/display-request/my_request_table/' + uniqueID + '">' + reqNum + '</a>';

    template.print(url);

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

AreKaveri_1-1705566458301.png

 

 

 

AreKaveri_0-1705566400410.png

 

 

 

Please help me why it is showing undefined (when i click on URL it was navigating to target record.).

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Replace

var uniqueID = current.getUniqueValue();

with

var uniqueID = current.sysapproval;

 

View solution in original post

1 REPLY 1

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Replace

var uniqueID = current.getUniqueValue();

with

var uniqueID = current.sysapproval;