The CreatorCon Call for Content is officially open! Get started here.

On the Service Portal, addInfoMessage disappears too quickly...

Alex Macdonel
Tera Expert

We've received complains that whenever we do an addInfoMessage on the portal, the message disappears too quickly. For example, after submitting a request:

find_real_file.png

Is there an quick and easy way to extend the delay before it the message disappears?

6 REPLIES 6

xiaix
Tera Guru

So I had an opposite need, where the notifications had to disappear after 1 second (they were sticking around too long).

Poking around in /scripts/js_includes_sp.jsx I found that I could do this within the Client Script of a Service Portal Widget:

spUtil.addInfoMessage("TEST");
$rootScope.$broadcast("$$uiNotification", {type: "info", message: "message"});
$scope.f_flushMessages = function() {
	$timeout(function(){
		$rootScope.$broadcast("$$uiNotification.dismiss");
	},1000);
};
$scope.f_flushMessages();

 

So, something to note... I went this route because the widget was in a scoped application, and you cannot use gs.flushMessages() in a scoped app!

 

 

Note: spUtil.addInfoMessage('message') is simply a shortcut for $rootScope.$broadcast("$$uiNotification", {type: "info", message: "message"});

 

Anyway... in my Server Side widget code, use a lot of gs.addInfoMessage() calls, but I do this to clear them quickly:

Client Script example

$scope.f_flushMessages = function() {
	$timeout(function(){
		$rootScope.$broadcast("$$uiNotification.dismiss");
	},1000);
};

$scope.someFunctionThatCallsServerCode = function() {
	c.server.update().then(function(response) {
		$scope.f_flushMessages();
	});
};

 

Server Script example:

(function() {
	if (input)
		gs.addInfoMessage("Hey, I updated!");
})();

 

Dominik H
Tera Guru

There is SN KB on this: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0713722

system property 'glide.service-portal.notification_timeout.seconds' controls it and accessibility settings