today I want to write a newer post about how to give an opportunity to user go to some link from Acumatica. As I've mentioned in https://blog.zaletskyy.com/types-of-redirects-in-acumatica, redirections are implemented as exception. Let consider next simple code, by which you can implement it:
In your page (in our example this is SO301000) a button will appear:
If user will click to this button, then he'll immediately receive requested data right in main window:
This approach has the disadvantage - the user will lose all unsaved data. So let's change our code to warn the user about it:
Now, after the user clicks on the "Learn More" button, a popup window will appear on the screen with a warning about the need to save the data:
It mach better. Warning is needed when using "Redirect0:" -"Redirect1:" and the link opens directly in the work window. But it is not necessary when using "Redirect3:" - "Redirect8:", because in this cases unsaved data is not lost, since the link is opened on another page (when to use "Redirect3:" - "Redirect5:") or in a popup (when to use "Redirect7:" and "Redirect8:"):
As we see, in Acumatica it is easy to direct the user to the link he wants.
today I want to say few words about new functions for redirect in Acumatica, and particularly about class PXRedirectHelper.
Classical approach from T200/T300 manual may look like this:
var currentCse = Cases.Current;
if(currentCse == null)
var graph = PXGraph.CreateInstance<CRCaseMaint>();
graph.Case.Current = graph.Case.Search<CRCase.caseCD>(currentCse.CaseCD);
if (graph.Case.Current != null)
throw new PXRedirectRequiredException(graph, true, "Case details");
But with new function all of those lines can be simplified to this:
PXRedirectHelper.TryRedirect(Cases.Cache, Cases.Current, "Edit case", PXRedirectHelper.WindowMode.NewWindow);
With that approach you'll get the same result, but just in one line of code.
today I want to write a few words on how to add links to some entites in Acumatica.
So, recently I've had an assignment to add redirect into existing grid, so intead of showing some text show nice link which will lead to Purchase order.
Here is what I've done in order to achieve it.
First of all I've noticed, what is primary DAC class in graph. It was VendFilt.
Then following steps were needed:
- create code for button:
public PXAction<VendFilt> gotoPOOrder;
[PXButton(Tooltip = "Open Purchase order")]
[PXUIField(DisplayName = "Open PO")]
public virtual void GotoPOOrder()
var poOrdEntryGraph = PXGraph.CreateInstance<POOrderEntry>();
var currentPoPorder = VendorOrders.Current;
poOrdEntryGraph.Document.Current = poOrdEntryGraph.Document.Search<POOrder.orderNbr>(currentPoPorder.OrderNbr);
if (poOrdEntryGraph.Document.Current != null)
throw new PXRedirectRequiredException(poOrdEntryGraph, true, "Purchase order Details");
2. Modify PXDataSource:
<px:PXDataSource ID="ds" runat="server" Visible="True" TypeName="Acumatica.PaymentsAllocation"
<px:PXDSCallbackCommand Name="GotoPOOrder" Visible="False" DependOnGrid="grdAllocation">
3. Modify grid column like this:
<px:PXGridColumn DataField="OrderNbr" LinkCommand="GotoPOOrder"></px:PXGridColumn>
And as result I've got nice link which lead to needed po order
today I want to note about redirects. In Acumatica you can redirect user to another webpage. Acumatica provides option of redirecting to following scenarios:
- To another page in Acumatica
- To another report
- To any destination url
Try to gues, how redirections are implemented? As exception. If you consider it as wrong approach, I can partially agree with you. But only partially, because redirecting to antoher page is really some kind of exceptional situation.
Below goes code of redirecting to page PM302000 at some TaskID and some projectid selected, which will be opened in new window:
UsrPMTaskReplace taskRepl = JiraAccountTasks.Current;
ProjectTaskEntry graph = PXGraph.CreateInstance<ProjectTaskEntry>();
graph.Task.Current = Base.Task.Current;
graph.Task.Current.ProjectID = taskRepl.UsrProjectID;
if (graph.Task.Current != null)
throw new PXRedirectRequiredException(graph, true, "Project Tasks");
If to speak more about other kinds of redirects, here it goes full list:
- PXRedirectRequiredException. Goes inside of Acumatica to some screen, or opens new one in another window. By default user will stay in the same window.
- PXPopupRedirectException. Inside Acumatica will be opened pop-up window.
- PXReportRequiredException. Opens report in the same or new window.
- PXRedirectWithReportException. This one is really cool because it can open two pages: the specified report in a new window, and the specified application page in the same window.
- PXRedirectToUrlException. Specified external page will be opened in a new window. BTW, you can use this exception for opening inquiry page.
today I want to notice what kind of redirections are available in Acumatica:
- 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.
- PXRedirectToUrlExceptionopens 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.