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

How do you prevent a form from adding itself to the navigation stack?

WilliamHazelrig
Giga Contributor

I'm familiar with the use of gs.getSession().getStack().pop() to remove the last URL on the stack; unfortunately, that only works after the URL you want to remove has been added. What I want to do is prevent a particular form from adding itself to the stack at all; I'd hoped that an "On Display" business rule might permit me to do this, but at the time such a rule runs the form involved has not finished loading and is not present on the stack. The form is not going to be updated (at least not intentionally), so moving the code to an "On Before Update" business rule wouldn't work.

Any suggestions?

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

You might be able to control this with a URL parameter. I'm not sure of any other way.

incident.do?sysparm_nostack=true


View solution in original post

4 REPLIES 4

Mark Stanger
Giga Sage

You might be able to control this with a URL parameter. I'm not sure of any other way.

incident.do?sysparm_nostack=true


geoffcox
Giga Guru

Have you tried putting your .pop in an onLoad Client Script (instead of a business rule).

What are you trying to achieve with this?

Alternatively, are you familiar with the following:
action.setRedirectURL()
and
action.setRedirect()
?
See also:
http://wiki.servicenow.com/index.php?title=Creating_a_UI_Routing_Action


I would love to do that; unfortunately, I haven't been able to find any way to access either the Session object returned by gs.getSession() or the stack object returned by gs.getSession().getStack() from within a client script. Do you know of a way to get at either of those objects within client script code?

Failing that, it might be possible to create a script include for the purpose and call it from a client script; that would be sub-optimal (relying as it does on an AJAX call) but I might be able to make it work.

Unfortunately, action.setRedirectURL() and action.setRedirect() are useless to me in this context; the form which we don't want recorded in the navigation stack is being loaded in an iframe, outside the normal navigation process and without involving any UI Action.


WilliamHazelrig
Giga Contributor

Mark's suggestion (using a querystring parameter, "sysparm_nostack=true") has solved this dilemma nicely. Thank you, Mark!