Service Portal (Helsinki): How to prevent confirmation messages from disappearing after a few seconds.

artsupsiri
Tera Contributor

I see the code in /scripts/js_includes_sp.jsx. I'd like to modify the function addNotification() in the Angular directive spNotifications so that non-trivial messages don't fade away.

Is there a way to change or extend the JavaScript?

1 ACCEPTED SOLUTION

artsupsiri
Tera Contributor

I discovered that decorating the directive spNotifications allows you to extend or overwrite the directive any way you want. In this case, I overrode two controller functions:



/* Override spNotificationsDirective controller */



angular.module('sn.$sp').config(function($provide) {


  $provide.decorator('spNotificationsDirective', function($delegate, $controller) {


    var directive = $delegate[0];



    var controllerName = directive.controller;


    directive.controller = function($scope) {


    var controller = $controller(controllerName, {$scope: $scope});



    // Override functions getMilliSeconds and areTrivial


 


    controller.getMilliSeconds = function() {


    var seconds = (areTrivial(controller.notifications)) ? 10 : 3000;


    return seconds * 1000;


    };



    function areTrivial(input) {


    return input.length >= 1 && input.every(function(item) {


    return item && item.type === 'trivial';


    });


    }



    return controller;


    };



    return $delegate;


  });


});


View solution in original post

12 REPLIES 12

aaron_moriartyC
Kilo Contributor

Hi,

 

We recently upgraded to Madrid and this script which was working fine has now broken with an error: 

Error: [$injector:unpr] Unknown provider

 

Could anybody figure out how to fix this error? We have logged a call with HI and they have simply pointed us to the error but have provided no solution.

 

Thanks all

Hello Aaron,

We also upgraded to Newyork, and this script throwing the 'Error: [$injector:unpr] Unknown provider: $elementProvider <- $element'. Did you get any workaround to fix this error? Pls assist if you find any info on this.

Thanks & Regards,

Indira Priya Darsini M.

Ronald Lob1
Tera Guru

London release added a new property that might be able to help:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0713722