Hello @rosenjon
There is a way to do this with special exception classes defined in Acumatica, as the article mentions:
- PXRedirectRequiredException opens the specified application page in the same window or a new one. By default, the user is redirected in the same window.
- PXPopupRedirectException opens the specified application page in a pop-up window.
- PXReportRequiredException opens the specified report in the same window or a new one. By default, the report opens in the same window.
- PXRedirectWithReportException opens two pages: the specified report in a new window, and the specified application page in the same window.
- PXRedirectToUrlException opens the webpage with the specified external URL in a new window. This exception is also used for opening an inquiry page that is loaded into the same window by default.
These are documented here: https://help-2022r1.acumatica.com/(W(62))/Help?ScreenId=ShowWiki&pageid=1fe245c2-b7de-42c7-a16c-217dc369c802
If opening your app in an external window, you could use PXRedirectToUrlException. Since Acumatica blocks externals sites from loading, it will ignore any WindowMode you set and will always open the url in a new window.
If you need to load the url inside the Acumatica frame, you would need to use the workaround the article shows. This is not documented because is not a recommended practice and you are basically using internal behavior for your benefit. This could change in a newer release, breaking your customization.
I did a simple action with both examples and query parameters worked as expected.
New window:
Using System.Web;
//...
public PXAction<SOOrder> openLink;
[PXButton(CommitChanges = true, DisplayOnMainToolbar = true), PXUIField(DisplayName = "Open Link", MapEnableRights = PXCacheRights.Select, Visible = true)]
protected virtual IEnumerable OpenLink(PXAdapter adapter)
{
// You should encode any part of the URL that could be invalid if used directly
string url = $"https://en.wikipedia.org/w/index.php?title=" + Uri.EscapeDataString("Acumatica") + "¶m2=" + Uri.EscapeDataString("Another parameter");
throw new PXRedirectToUrlException(url, "App");
}
Inside Acumatica:
Using System.Web;
//...
public PXAction<SOOrder> openLink;
[PXButton(CommitChanges = true, DisplayOnMainToolbar = true), PXUIField(DisplayName = "Open Link", MapEnableRights = PXCacheRights.Select, Visible = true)]
protected virtual IEnumerable OpenLink(PXAdapter adapter)
{
// You should encode any part of the URL that could be invalid if used directly
string url = $"https://en.wikipedia.org/w/index.php?title=" + Uri.EscapeDataString("Acumatica") + "¶m2=" + Uri.EscapeDataString("Another parameter");
throw new Exception($"Redirect0:{url}");
}
Take note that in order to be able to open sites inside an iframe, that site should allow it (I’m using wikipedia.com because it works, google.com for example, doesn’t), Most modern browsers will refuse to load any site that does not allow it explicitly.