Search code examples
customizationacumaticaerpacumatica-kb

Acumatica - How to change the page opened by the edit button (pencil)


I'm trying to customize a page so that the edit button (the pencil icon one) directs the user to a specific page. In my case, the edit button is linked to a BAccountID field : enter image description here

By default, it opens the Business Account's page (page CR303000): enter image description here

I would like it to open a different page that I created that has a similar BAccount view (page AR303001) : enter image description here

Can this be done ? And how ? I can't seem to find the code behind this logic.


Solution

  • The target graph is declared in the PXPrimaryGraph attribute decorating the DAC. BAccount DAC is a special case that uses a more complex attribute (CRCacheIndependentPrimaryGraphList) that inherits from PXPrimaryGraph.

    [CRCacheIndependentPrimaryGraphList(new Type[]{
        typeof(CR.BusinessAccountMaint),
        typeof(EP.EmployeeMaint),
        typeof(AP.VendorMaint),
        typeof(AP.VendorMaint),
        typeof(AR.CustomerMaint),
        typeof(AR.CustomerMaint),
        typeof(AP.VendorMaint),
        typeof(AR.CustomerMaint),
        typeof(CR.BusinessAccountMaint)},
        new Type[]{
            typeof(Select<CR.BAccount, Where<CR.BAccount.bAccountID, Equal<Current<BAccount.bAccountID>>,
                    And<Current<BAccount.viewInCrm>, Equal<True>>>>),
            typeof(Select<EP.EPEmployee, Where<EP.EPEmployee.bAccountID, Equal<Current<BAccount.bAccountID>>>>),
            typeof(Select<AP.VendorR, Where<AP.VendorR.bAccountID, Equal<Current<BAccount.bAccountID>>>>), 
            typeof(Select<AP.Vendor, Where<AP.Vendor.bAccountID, Equal<Current<BAccountR.bAccountID>>>>), 
            typeof(Select<AR.Customer, Where<AR.Customer.bAccountID, Equal<Current<BAccount.bAccountID>>>>),
            typeof(Select<AR.Customer, Where<AR.Customer.bAccountID, Equal<Current<BAccountR.bAccountID>>>>),
            typeof(Where<CR.BAccountR.bAccountID, Less<Zero>,
                    And<BAccountR.type, Equal<BAccountType.vendorType>>>), 
            typeof(Where<CR.BAccountR.bAccountID, Less<Zero>,
                    And<BAccountR.type, Equal<BAccountType.customerType>>>), 
            typeof(Select<CR.BAccount, 
                Where2<Where<
                    CR.BAccount.type, Equal<BAccountType.prospectType>,
                    Or<CR.BAccount.type, Equal<BAccountType.customerType>,
                    Or<CR.BAccount.type, Equal<BAccountType.vendorType>,
                    Or<CR.BAccount.type, Equal<BAccountType.combinedType>>>>>,
                        And<Where<CR.BAccount.bAccountID, Equal<Current<BAccount.bAccountID>>,
                        Or<Current<BAccount.bAccountID>, Less<Zero>>>>>>)
        },
        VerifyRightsBy = new [] { typeof(CR.BusinessAccountMaint) })]
    

    There is no way to easily customize this attribute. To change it would you need to replace the BAccount DAC with another one. The preferred method for your use case is to avoid usage PXPrimaryGraph attribute by using a regular action button.

    The action button can be configured to show the pencil icon: Make PXButton appear as pencil icon

    And it can be displayed beside the field using PXLayout Merge property or you can use LinkCommand to redirect: https://stackoverflow.com/a/60446714/7376238