Change timeout for spUtil.addErrorMessage on Portal

David Morden
Mega Expert

I have a client that would prefer to have a disclaimer on their community page, but they want it as a "splash" message like an error message.   However, they want to extend the timeout on it so that it lasts for 10 seconds.   I have tried several iterations of different options with no luck.   Here is my base code to play with, and as always, any help is GREATLY appreciated.

HTML Template

<sp-widget widget="c.cri_community_disclaimer"></sp-widget>

Client Script

function($scope, spUtil){

      var c = this;

      $scope.m = $scope.data.msgs;

      spUtil.addErrorMessage($scope.m.disclaimerMsg);

}

Server Script

(function() {

  var m = data.msgs = {};

      m.disclaimerMsg = gs.getMessage("This is the content of the message");

})();

1 ACCEPTED SOLUTION

Here it is. I actually looked a bit more and it could be even simpler. This is the widget you can place where you want.



This code will show the "div" and it's content for 5000 milliseconds..



This is all you need for that. But I guess you probably wanna style it some more



find_real_file.png


View solution in original post

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi David,



I know this is on the Kingston release, but perhaps it's ok for the client to wait and use that instead. what I'm talking about is the announcement functionality. Here is a great overview from ServicePortal.io about it: The Road to Kingston: Announcements (Part 1 of 3) - ServicePortal.io - Service Portal, CMS, and Cust...          


I definitely appreciate the reminder about the new feature in Kingston.   However, the client is a VERY slow adopter of change due to other "home grown" application integrations.



Any thoughts on how to accomplish this in Jakarta?


Hi David,



I don't think you can mess with the addErrorMessage to work as you want.


Now I'm just thinking here. But you would be able to create a own widget, with the info and in the link function add a timer, so after 10 secs it will set display:none on element having the message so it will disappear. Haven't don that, but should work and not so hard to do.


It sounds like it's worth a shot, but I'm having a hard time following you.   Would you mind including an example?