Redirection to Webpages: General Information
This lesson describes two types of redirection to webpages you can implement on an MYOB Acumatica form:
- Adding a simple redirection link to the grid of a form by using the PXSelector attribute.
- Adding a redirection link by using an action. By using this approach, you can also add conditional logic to the form so that a redirection link opens different forms, depending on whether a specified condition is met.
Learning Objectives
In this chapter, you’ll learn how to do the following:
- Add a redirection link by using the PXSelector attribute on a DAC field
- Add a redirection link by implementing an action with a corresponding button on the form
- Redirect the user to a report at the end of a processing operation
Applicable Scenarios
You add redirection to a webpage on a form when you need to give users the ability to open one of the following:
- A record's data entry form with the record displayed, so that a user can get detailed information about that record
- A report or a generic inquiry related to the record
- Any destination URL
Redirection Link from a Selector Control
A redirection link from a selector control is often used for opening the data entry form on which the record was created. The user can then view the selected record and make any needed edits. You can add redirection from a selector control declaratively by doing the following:
- Adding the PXSelector attribute to a field in its data access class
- Adding the PXPrimaryGraph attribute to the DAC that corresponds to the record in the selector control
- Configuring the selector control as described in Selector Control: Configuration of a Link
Redirection in an Action
To implement redirection in an action, you need to throw one of the exceptions provided by the MYOB Acumatica Framework. Once an exception is thrown, it interrupts the current context and propagates up the call stack until it’s handled by the MYOB Acumatica Framework, which performs the redirection. (This mechanism doesn’t affect the performance of the application.)
The following exceptions are used for redirection:
- PXRedirectRequiredException opens the specified application page in the same window (the default behavior) or a new one.
- PXPopupRedirectException opens the specified application page in a pop-up window.
- PXReportRequiredException opens the specified report in the same window (the default behavior) or a new one.
- 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’s loaded into the same window by default.
If you want to add a redirection link that’s implemented by using an action, you need to configure the selector control as described in the Link Behavior section of Selector Control: Configuration of a Link.
Handling of Redirection Exceptions
In most cases, you don’t need to implement the handling of exceptions that are used for redirection.
catch block of the exception
handler. The following code example shows how this is
implemented.using PXTransactionScope tranScope = new();
try
{
// Do something that may throw any kind of redirect exception
tranScope.Complete();
}
catch(PXBaseRedirectException redirect){
tranScope.Complete();
throw;
}Note that in the above code, a PXBaseRedirectException has been used. All the exceptions listed in the preceding section are derived from this base class.
