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.

Can someone help me on this email notification notification

NagaNandini N
Tera Guru

Hi All,

 

Can someone help me with the below email notification code modification?

It was earlier: View request: RITM0030864  and I would require: only a view request in a button text and clicking the button text should redirect to the portal page.

 

Please find the screenshot for reference.

 

Please find the existing code for reference.

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=sc_req_item&sys_id=' + current.sys_id + '">' + current.number + '</a>';
template.print('<span style="font-family: Arial, sans-serif; font-size: 16px;">View request: ' + url + '</span>');

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

 

1 ACCEPTED SOLUTION

NagaNandini N
Tera Guru
Hi All,
 
Thank you for your answers.
The below posted code works perfect and fulfill my request.
 
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

//var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=sc_req_item&sys_id=' + current.sys_id + '">' + current.number + '</a>';
//template.print('<span style="font-family: Arial, sans-serif; font-size: 16px;">View request: ' + url + '</span>');

    var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();
    var requestUrl = '/' + portalSuffix + '?id=ticket&table=sc_req_item&sys_id=' + current.sys_id;
    var buttonText = gs.getMessage('View request');

    //Generates primary action of view requested item

    var requestNotificationJs = new global.RequestNotificationUtil();
    requestNotificationJs.createNotificationPrimayAction(template, requestUrl, buttonText);

    //request details required for notification template
   
    var requestDetails = requestNotificationJs.getRequestDetails(current.sys_id, current);

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

View solution in original post

8 REPLIES 8

Siva Sai Teja
Tera Expert

Hi @NagaNandini N, try like this

 

var link = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=sc_req_item&sys_id=' + current.sys_id + '">' + current.number + '</a>';
 
    var backgroundColor = 'background-color: #278efc;';
    var border = 'border: 1px solid #0368d4;';
    var color = 'color: #ffffff;';
    var fontSize = 'font-size: 16px;';
    var fontFamily = 'font-family: Helvetica, Arial, sans-serif;';
    var textDecoration = 'text-decoration: none; border-radius: 3px;';
    var webKitBorder = '-webkit-border-radius: 3px;';
    var mozBorder = '-moz-border-radius: 3px;';
    var display = 'display: inline-block;';
    var padding = 'padding: 5px;';
 
template.print('<a href="' + link + '"');
template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);
    template.print('">');
    template.print(gs.getMessage('View Request'));
    template.print('</a>');
    template.print('</font>');
    template.print('<br><br>');
    template.print('<p><font size="3" color="#808080" face="helvetica">');
    template.print(gs.getMessage('Thank you.'));
    template.print('</font></p>');
Please Mark Correct if this solves your query and also mark  Helpful if you find my response worthy based on the impact.

Thanks

The given code doesnot work. Please see the screenshot for refereceSC3.PNG

dgarad
Giga Sage

Hi @NagaNandini N 

 

change below code 

template.print('<span style="font-family: Arial, sans-serif; font-size: 16px;"<a href=' + url + '>View request: </span>');
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

No, it's not working. The code is incomplete and I need a box button as shown in sc_2. If you could help it would be great.