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

luffy3478
Tera Guru

${URI_REF}

If you add this in to the email body. I think you need not use the script

Maddysunil
Kilo Sage

@NagaNandini N 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
    var url = gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=sc_req_item&sys_id=' + current.sys_id;
    var buttonText = 'View request';

    // Adjust styles for the button
    var buttonStyle = 'background-color: #4CAF50; /* Green */' +
                      'border: none;' +
                      'color: white;' +
                      'padding: 15px 32px;' +
                      'text-align: center;' +
                      'text-decoration: none;' +
                      'display: inline-block;' +
                      'font-size: 16px;' +
                      'margin: 4px 2px;' +
                      'cursor: pointer;';

    // Print the button
    template.print('<button style="' + buttonStyle + '" onclick="window.location.href=\'' + url + '\'">' + buttonText + '</button>');
})(current, template, email, email_action, event);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

View Request link button does not work

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);