Can someone help me how to redirect the esc portal view to the sp portal view in ServiceNow

NagaNandini N
Tera Guru

Hi Can some one help me how to redirect the esc portal view to the sp portal view in ServiceNow request notification. 

 

1. Email notification links redirects to sp portal view and its redirecting to esc portal view. Is there is a way to check from onwards this modification happened in ServiceNow.

2. For the new requests creation notification it directs to sp portal but for the old request the link directs to esc portal. Please find the code for reference. Is it possible to put the old request link to sp portal view. 

Earlier code

    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');
Current code 
    var portalSuffix = 'sp';
    var requestUrl = '/' + portalSuffix + '?id=ticket&table=sc_req_item&sys_id=' + current.sys_id;
    var buttonText = gs.getMessage('View request');
3. Is it possible to disable the employee center notification permanently ?
 
Regards,
Naganandini N
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@NagaNandini N 

which OOTB email notification is this? share the name and screenshots

You want always it should be redirected to esc ?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I want it to be redirected to the sp portal . 

It is an OOB notification. I want to modify the email notification script. Please see the screenshot for reference. I have shared the entire code of email notification script below

of the (about_the_request_ijm). Please help me on this

 

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

          // Add your code here
    //var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();
    var portalSuffix = 'sp';
    var requestUrl = '/' + portalSuffix + '?id=order_status&table=sc_request&sys_id=' + current.sys_id;
    var buttonText = gs.getMessage('View request');
    //Generates primary action of view request
    var requestNotificationJs = new global.RequestNotificationUtil();
    requestNotificationJs.createNotificationPrimayAction(template, requestUrl, buttonText);

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


    template.print('<div style="font-size: 15pt; line-height:30px; padding-bottom:16px"><b style="font-weight:600">About this request</b></div>');

    var priceDisplay = gs.getProperty('glide.sc.price.display');
    var showRequestPrice = false;
    if (requestDetails.totalTasks > 1 && priceDisplay !== 'never' && current.price > 0) {
        showRequestPrice = true;
    }
    var showOpenedBy = false;
    if (current.opened_by.toString() !== current.requested_for.toString()) {
        showOpenedBy = true;
    }
    var requestItemsPadding = 'padding-top:16px;';
    if (showOpenedBy || showRequestPrice) {
        template.print('<div style="padding-bottom:16px">');

        if (showOpenedBy) {
            if (requestDetails.showRequestedFor) {
                template.print('<div>Requested for: ' + '<b style="font-weight:600">' + current.state + '</b></div>');
            }
            template.print('<div>Requested for: ' + '<b style="font-weight:600">' + current.requested_for.name + '</b></div>');
            template.print('<div>Opened by: ' + '<b style="font-weight:600">' + current.opened_by.name + '</b></div>');
        }
        if (showRequestPrice) {
            var recurringPriceText = requestNotificationJs.gerRecurringPriceRollup(current.sys_id);
            template.print('<div>Total price: ' + '<b style="font-weight:600">' + current.price.getDisplayValue() + '</b><span style="font-size:14px;font-weight: 600">' + recurringPriceText + '</span></div>');
        }
        template.print('</div>');
    } else {
        requestItemsPadding = '';
    }

    if (requestDetails.totalTasks > 1) {

        template.print('<div style="font-size: 12pt;font-weight:600;' + requestItemsPadding + '">Requested items (' + requestDetails.totalTasks + ')</div>');
    }
    requestDetails.tasks.forEach(function(task, index) {
        var borderBottom = 'border-bottom:1px solid #DADDE2';
        if (requestDetails.totalTasks > 1) {
            template.print('<div style="padding-top:16px;padding-bottom:16px;');
        } else {
            template.print('<div style="padding-bottom:16px;');
        }
        if (requestDetails.totalTasks > requestDetails.tasks.length || (index + 1 < requestDetails.tasks.length)) {
            template.print(borderBottom);
        }
       template.print('">');
        template.print('<div>Requested item number: <b style="font-weight:600">' + task.requestNumber + '</b></div>');
        template.print('<div>Short description: <b style="font-weight:600">' + task.item + '</b></div>');
        //if (task.showItemRequestedFor) {
         //template.print('<div>Requested for: <b style="font-weight:600">' + task.requestedFor + '</b></div>');
        //}
        if (task.showQuantity) {
            template.print('<div>Quantity: <b style="font-weight:600">' + task.quantity + '</b></div>');
        }
        requestNotificationJs.setPricingtoTemplate(task, template);
        template.print('</div>');
    });
    if (requestDetails.totalTasks > 3) {
        template.print('<div style="padding-bottom:16px;padding-top:16px;color:#3C59E7"><a href="' + requestUrl + '">');
        template.print(gs.getMessage('View all items'));
        template.print('</a></div>');
    }

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

@NagaNandini N 

I could see that's not OOTB notification on sc_request.

The OOTB has name -> Request opened

Did you rename the OOTB one and created your own copy of that email script?

If yes and in entire instance you want sp then it's fine.

But remember since you updated an OOTB notification you will not get any updates to this when instance upgrades.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Juhi Poddar
Kilo Patron

Hello @NagaNandini N 

 

  • The method getPortalSuffix() from the FoundationNotificationUtil Script Include (part of Employee Experience Foundation) returns the ESC portal prefix by default. 

  • Hardcoding var portalSuffix = 'sp'; forces all links to open in Service Portal—even for old requests—which is a good workaround if you prefer SP.

  • It's best not to edit scoped Script Includes directly, as they may be overwritten during upgrades.

 

This maybe useful: Approval Links in a Notification - direct to Service Portal not Employee Center

Hope this helps!

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar