Approval Links in a Notification - direct to Service Portal not Employee Center

terrieb
Tera Guru

We have Not deployed Employee Center yet, and not planning do so for a while.

 

We had built an approval notification that is for staff outside of the department to approve via the Service Portal.  This worked just fine until we upgraded to San Diego.  Now that link (email script) is redirecting them to the Employee Center and they are unable to approve.

 

Below is current mail script that needs to be modified

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var requestItemId = current.sysapproval;
    var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();
    var requestUrl = portalSuffix + '?id=ticket&table=sc_req_item&sys_id=' + requestItemId;
    var colorTheme = 'color: #4F52BD;';
    var fontSize = 'font-size: 16px;';
    var lineHeight = 'line-height: 24px;';
    var fontFamily = 'font-family: Lato, Arial, sans-serif;';
    var display = 'display: inline-block;';
    template.print('<div style="padding-bottom:36px"> <span style="margin-right: 4px;">View</span> <a href="' + requestUrl + '"');
    template.print('style="' + colorTheme + fontSize + fontFamily + display);
    template.print('">');
    template.print(gs.getMessage('approval request'));
    template.print('</a></div>');
    var request = {};
    request.requested_for = current.sysapproval.request.requested_for;
    request.opened_by = current.sysapproval.request.opened_by;

    var notificationUtil = new global.RequestNotificationUtil();
    var requestItemDetails = notificationUtil.getRequestItemDetails(requestItemId, request.requested_for, true);

    template.print('<div style="padding-bottom:18px;font-size: 15pt;"><b style="font-weight: 600;">About this request</b></div>');
    template.print('<div style="padding-bottom:18px;">');
    if (requestItemDetails.showItemRequestedFor) {
        template.print('<div style="' + fontSize + lineHeight + '">Requested for: ' + '<b style="font-weight: 600;">' + requestItemDetails.requestedFor + '</b></div>');
    }
    if (request.requested_for.toString() !== request.opened_by.toString()) {
        template.print('<div style="' + fontSize + lineHeight + '">Opened by: ' + '<b style="font-weight: 600;">' + request.opened_by.name + '</b></div>');
    }

    template.print('<div style="' + fontSize + lineHeight + '">Short description: <b style="font-weight: 600;">' + requestItemDetails.item + '</b></div>');
//
    if (requestItemDetails.variables.length > 0) {
        notificationUtil.setRequestItemVariablestoTemplate(requestItemDetails, template);
		//
    }
    if (requestItemDetails.showQuantity) {
        template.print('<div style="' + fontSize + lineHeight + '">Quantity: <b style="font-weight: 600;">' + requestItemDetails.quantity + '</b></div>');
    }
    notificationUtil.setPricingtoTemplate(requestItemDetails, template);
    template.print('</div>');

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

 Attaching screen shots of both the email and action that happens when recipient (approver) clicks the link in the email to approve request

 

Thanks!

3 REPLIES 3

Gustavo Olivei1
Tera Contributor

Hello, check this script include to have more visibility of the portal.

var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();

 

Also, you can modify this entry (not recommended) to force your instance to avoid the ESC:

https://yourinstance.service-now.com/nav_to.do?uri=%2Fsys_properties.do%3Fsys_id%3D3b29766999033010f...

 

We want it to redirect to the current service portal as the new employee center portal approval is not functioning - it states that it accepts the approval, but does not actually update the record.

 

For example, we have a request that goes out for approval, the approver gets the email link, and clicks on it which redirects them to the employee center site.  In the "My To Do's" it's listed there, and the person clicks on the "approve" action button.  The banner comes up stating the request was approved, however, when we look at the requested item record, it still states awaiting approval...  

 

Before the employee center was activated, it was directing them to the service portal and they had no issues with approving requests there.  Now they can't approve.

 

That is why we were looking to "fix" that line of script in the mail script of the notification:  

var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();

 

Thanks

Hi terrieb

just had the same issue - put off sorting it out until we just moved to Washington as the number of users that actually clicked the link was quite small.

 

In our case I was able to comment out the original line - and replace it with a more specific value

 
    //var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();
    var portalSuffix = "thc/"; // SN - specify the actual portal - added 11/07/2024 - testing
    var requestUrl = '/' + portalSuffix + '?id=order_status&table=sc_request&sys_id=' + current.sys_id;
    var buttonText = gs.getMessage('View request');
 
We now get the right portal - the content isn't much better on landing so I suspect I have more work to do configuring that now 🙂
 
We're actually considering removing the link altogether and replacing with a friendly text to check the REQ number in the portal as you would normally do etc.