Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Info Message not Dissapearing

Coder2
Tera Contributor

How should I remove the info message from the portal once I call it from the spUTIL in client script, tried many ways, the latest is at the bottom. I dont want to do it through Backend, only frontend.  Is there any way to add a timer on infomessage so it goes away on the portal from the frontend, again NO BACKEND?

<div>
<!-- your widget template -->
  <h1>Hello Worls</h1>
  <button type="button" class="btn btn-primary" ng-click="func()">Primary</button>
</div>

api.controller=function($scope, $location, $rootScope, spUtil, $timeout, spModal) {
	/* widget controller */
	var c = this;
	//var msg = spUtil.addInfoMessage('HEELO WORLS');

	$scope.func = function(){
		//c.data.action = 'boom';
		//console.log('func called');
		$scope.page.gs.clearMessages();
		c.server.update().then(function(response){
			c.server.refresh();
		})
	}
};

(function() {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */
	//gs.flushMessages()
	//gs.addInfoMessage("Hello");
	gs.flushMessages();
	if(input && input.action == 'boom'){
		
		console.log('called')
		console.log("cased")
		gs.flushMessages();
	}
	

})();
1 REPLY 1

AnubhavRitolia
Mega Sage

Hi @Coder2 

 

Please find the link below which map help you with your issue:

 

https://www.servicenow.com/community/developer-forum/remove-infomessage-after-specified-time/m-p/209...

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023