Redirecting to External Page from Button

Hi There,

Want to share with you my experience with working with redirects from Acumatica.

redirects from Acumatica

You may know that due to security issues and stability of software, redirect to external web site in the iFrame is forbidden in Acumatica.
So every time when you use “PXRedirectToUrlException” for url like “” system will open url in separate window/tab. That is OK in mane cases, but sometimes you really need that functionality.

One way to solve that issue is well described in a separate article – Redirect on Page Load
But that one is applicable only if you want to have a menu item in Acumatica SiteMap.

If you want to redirect use based on internal logic/code, that this way may not be the best.
To understand how to solve that issue, I want to explain how redirects works in Acumatica first.

You know there there are multiple redirect exceptions available:

  • PXRedirectRequiredException
  • PXRedirectToUrlException
  • PXRedirectWithReportException
  • PXRedirectToGIException
  • And many others.

But basically all of them are different only in how system search for required URL and with cache of items (if you redirect to another screen). So for example “PXRedirectRequiredException” will find URL from sitemap based on graph type to what you do redirect.

After url is determined, system cancel current round trip and returns a special message back to JavaScript in the page. This message is “eRedirect<CODE>:<URL>” keyword with url and no other data.
<CODE> – is a number from 1 to 8 that defines how system should open new page

  • Redirect0 – open page in the same iFrame with no keeping session
  • Redirect1 – same as above but with keeping session
  • Redirect5, Redirect6 – same as above but with new popup
  • Redirect3 – will open new frame-set
  • Redirect7, Redirect8 – will open a new window

So as soon as you know how does it work, there is simple solution – throw your own exception with specific code instead of standard one:

public PXAction<PX.Objects.PO.POReceipt> Redirect;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Redirect")]
protected void redirect()
   throw new Exception("Redirect0:" + "");

That code will open Acumatica page in the same frameset, just as an inner page.

redirects from Acumatica

Have a nice redirection!

Leave a Reply

Your email address will not be published. Required fields are marked *