Skip to main content

How to Override the Default Navigation for DAC

  • 14 June 2024
  • 1 reply
  • 52 views

Hi Community,

This post is dedicated to the default navigation mechanism in Acumatica. It is based on the following page from the Acumatica Help Portal which describes the PXPrimaryGraphAttribute:
https://help.acumatica.com/Help?ScreenId=ShowWiki&pageid=842ed8f6-e659-45ef-3083-6696cf1fecaf

Default Navigation Overview

 

Acumatica Framework provides built-in navigation capabilities for DACs via the PXPrimaryGraph attribute mechanism. It allows to specify for a DAC a screen that should be used as a default screen. The DAC for which you specify the default screen is usually the primary DAC of this default screen. Such way of navigation is sometimes called default navigation. Default navigation is used widely in the product in the following locations:

  • Default navigation to a document from a generic inquiry
  • Navigation to a document from a report
  • Opening a document for editing from another screen (the "pencil" button in the UI)
  • Navigation to a document from the search results
  • Navigation to a document from user history and favorite records
  • There are some other uses of default navigation which are also widely used and not listed here.

You configure default navigation by declaring the PXPrimaryGraphAttribute attribute on a DAC and passing the type of the screen graph as a parameter as the following code shows:

>PXPrimaryGraph(typeof(MyGraph))]
public class MyDac : IBqlTable
{}

Overriding Default Navigation

 

Sometimes you may need to change the default navigation for an existing DAC. For example, you need to override the navigation if a screen is duplicated. Suppose that the copy of an existing screen is added to Acumatica ERP with some small modifications. Now default navigation of the DAC should be directed to the copy of the screen instead of the original screen. There may be different business reasons to do this, such as simplified UI or small changes to the business logic.

However, it is not obvious how to change the default navigation because the PXPrimaryGraphAttribute attribute is declared not on some DAC field property but on a DAC itself. Thus the declaration cannot customized with usual customization approaches like replacing the attributes in graph's cache attached events or in a DAC extension. Fortunately, the PXPrimaryGraphAttribute mechanism provides several options for the customization:

  • Declare PXPrimaryGraphAttribute on a graph;
  • Declare PXPrimaryGraphAttribute on a graph extension;
  • Declare PXPrimaryGraphAttribute on a DAC extension;

The following sections describe them.

Declaring attribute on a graph

The first option to customize the PXPrimaryGraphAttribute mechanism is to declare the PXPrimaryGraphAttribute attribute on a graph of the screen to which you wish to redirect the user. As a parameter, specify the type of the DAC for which the navigation should be redefined. The declaration is illustrated by the following example of the PX.SM.AccessUsers graph.

"PXPrimaryGraph(typeof(Users))]
public class AccessUsers : Access
{...}

Declaring attribute on a graph extension

The second option is to declare the PXPrimaryGraphAttribute attribute on a graph extension for a graph of the screen to which you wish to redirect the user. As a parameter, specify the type of the DAC for which the navigation should be redefined. It should be similar to this code:

"PXPrimaryGraph(typeof(MyDac))]
public class MyGraphExtension : PXGraphExtension<MyGraph>
{...}

You can use this approach if you need to override a default navigation declared via PXPrimaryGraphAttribute attribute placed on a graph.

Declaring attribute on a DAC extension

Another option is to declare the PXPrimaryGraphAttribute attribute on a DAC extension. The declaration of the attribute for DAC extensions is the same as the declaration for DACs. Example is shown in the following code:

PXPrimaryGraph(typeof(AnotherGraph))]
public class MyDacExtension : PXCacheExtension<MyDac>
{}

Order of overrides

 

A natural question arises. What if we apply more than one customization for the default navigation? In which order are the default navigation overrides applied? Here is the answer:

  1. First of all the system looks for the suitable default navigation declaration among graph extensions. This is the reason you can override PXPrimaryGraphAttribute declaration on a graph with a graph extension.
  2. If no suitable declaration was found the system looks for the suitable default navigation declaration among graphs;
  3. If no suitable declaration was found the system looks for the suitable default navigation declaration among DAC extensions;
  4. If no suitable declaration was found the system looks for the suitable default navigation declaration among DACs;

There is actually some additional complexities related to the PXParentAttribute but they are out of scope of this post.

Thank you for your attention!

Thank you for sharing this tip with the community @snikomarov36!


Reply