How to stop redirection from an After - Update Business Rule

TT3
Kilo Guru

I have a after-update BR in which I am calling Server side script include function. ServiceNow is redirecting user to recently visited page after execution. I need to stop that and user should stay on the record itself. Any idea how to stop recirecting?

Here is the BR snippet:

(function executeRule(current, previous /*null when async*/) {

try {
		 
        gs.eventQueue('process.file',current,current.getUniqueValue(),gs.getUserName());
		
	gs.addInfoMessage('File processing has been scheduled successfully.');
	//above message appears on another page where user gets recirected.

} catch (e) {

	gs.addErrorMessage('Error processing file.<BR>' + JSON.stringify(e));
	current.setAbortAction(true);
}

})(current, previous);
1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi

you can try

var url = gs.generateURL(current.getTableName(), current.sys_id);

gs.setRedirect(url);

Kind regards
Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

you can try

var url = gs.generateURL(current.getTableName(), current.sys_id);

gs.setRedirect(url);

Kind regards
Maik

That worked, should I do this at the end? Also, why SNOW was redirecting by default? is there any global property as I have other BRs and don't want to write repeatedly in all of them.

I mean, why we have to redirect to the same page? can't we just stop redirecting?