Solved

How can I add additional columns to the Reference Nbr. column selector?


Userlevel 7
Badge +5

I went through the process of creating the customization project and then added AP.APAdjust.  I clicked on Selector Columns and then added APAdjust__vendorID and APPayment__extRefNbr.

I saved the changes and published the customization but when viewing the selector within the detail grid of AP503000 I did not see the columns that I added.

Just in case, I also replaced the attributes of the APAdjust VendorID column from

[Vendor(Visibility = PXUIVisibility.Visible, Visible = false)]
[PXDBDefault(typeof(APPayment.vendorID))]

to

[Vendor(Visibility = PXUIVisibility.Visible, Visible = true)]
[PXDBDefault(typeof(APPayment.vendorID))]

but that didn’t have the desired effect.

What did I miss?

icon

Best answer by KishoK 6 May 2021, 10:52

View original

8 replies

Userlevel 2

@ddunn 
please elaborate your question in more descriptive manner, the screen you mentioned here is process screen and there are two vendor fields available here,one is in header and another in in lines. What are you trying to achieve …?  

Userlevel 7
Badge +5

Hi @KishoK - thanks for looking at my question!

In the detail grid of AP503000 is the Reference Nbr. column with a selector.  If I want to manually add a document for payment to this grid I’ll use the selector on that column to locate a document. However, the selector fields are missing some columns to help the user know which documents to select.  I’d like to add the Vendor ID and Vendor Name to the fields displayed.

 

Userlevel 7
Badge +17

Hi @ddunn,

As you need to add “Vendor ID” and “Vendor Name” fields to the Ref Nbr selector in the Documents TO PAY tab, the below article is well explained how to add the fields to the Selector without any code changes. Please find the link below.

This is very easy!!

 

https://www.info-sourcing.com/how-to-add-fields-to-acumatica-selector-lookup-no-coding/

 

hope this helps!!

Userlevel 2

Hi @ddunn 
Seems the Acumatica’s recommended standard method mentioned above won’t work in this case, 
the attributes of the Reference Nbr are already overode in the graph which has its own Search2<> BQL statement, 
So your best bet is overide the attributes again in Graph extension, here comes the tricky part 
even if you overide all the attributes using cache attached method, use of APInvoiceType.AdjdRefNbr attribute won’t yield you any difference since the selector columns already defined in the attribute level,
So to achieve your desired output you need to create your own Selector attribute. 
Follow the code attached below
 

using System;

using PX.Common;

using PX.Data;
using PX.Data.BQL;
using PX.Data.EP;

using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.TX;
using PX.Objects.CR;
using PX.Objects.AP;
using PX.Objects.CA;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Objects.AP.MigrationMode;
using PX.Objects.AR;
using PX.Objects.Common.Attributes;
namespace T_Project
{
  public class CustAdjdRefNbrAttribute : PXSelectorAttribute
    {
      public CustAdjdRefNbrAttribute(Type SearchType)
        : base(SearchType,
        typeof(APRegister.branchID),
        typeof(APRegister.refNbr),
        typeof(APRegister.docDate),
        typeof(APRegister.finPeriodID),
        typeof(APRegister.vendorLocationID),
        typeof(APRegister.curyID),
        typeof(APRegister.curyOrigDocAmt),
        typeof(APRegister.curyDocBal),
        typeof(APRegister.status),
        typeof(APAdjust.APInvoice.dueDate),
        typeof(APAdjust.APInvoice.invoiceNbr),
        typeof(APRegister.docDesc),
        typeof(APRegister.vendorID),
        typeof(APRegister.vendorID_Vendor_acctName)
)
      {
      }

      protected override bool IsReadDeletedSupported => false;
    }
    
}

I created a project called T_Project and copied the system standard AdjdRefNbr attribute to a newly created CustAdjdRefNbr attribute and did some changes in selector columns (Added vendor ID and Vendor_acctName), once you done with this you can override the whole attributes in graph extension.
Follow the attached code below
 

using System.Diagnostics;
using PX.Objects.Common.MigrationMode;
using PX.Objects.AR;
using PX.Objects.TX;
using PX.Objects.AP.Standalone;
using PX.Objects.GL.FinPeriods.TableDefinition;
using PX.Data.ReferentialIntegrity.Attributes;


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using PX.Data;
using PX.Objects.CR;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.Common;
using PX.Objects.Common.Extensions;
using PX.Objects.CS;
using PX.Objects.AP.MigrationMode;
using PX.Objects.Common.Utility;
using PX.Objects.GL.FinPeriods;
using PX.Objects;
using PX.Objects.AP;
using T_Project;

namespace PX.Objects.AP
{
  public class APPayBills_Extension : PXGraphExtension<APPayBills>
  {
        #region Event Handlers


        //[key] Reference number of the adjusted document.
        /// </summary>
        [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
        [PXDefault()]
        [PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.Visible)]
        [CustAdjdRefNbr(typeof(Search2<
            APInvoice.refNbr,
            InnerJoin<BAccount,
                On<BAccount.bAccountID, Equal<APInvoice.vendorID>,
                And<Where<
                    BAccount.status, Equal<BAccount.status.active>,
                    Or<BAccount.status, Equal<BAccount.status.oneTime>>>>>,
            LeftJoin<APAdjust,
                On<APAdjust.adjdDocType, Equal<APInvoice.docType>,
                And<APAdjust.adjdRefNbr, Equal<APInvoice.refNbr>,
                And<APAdjust.released, Equal<False>,
                And<Where<
                    APAdjust.adjgDocType, NotEqual<Current<APPayment.docType>>,
                    Or<APAdjust.adjgRefNbr, NotEqual<Current<APPayment.refNbr>>>>>>>>,
            LeftJoin<APPayment,
                On<APPayment.docType, Equal<APInvoice.docType>,
                And<APPayment.refNbr, Equal<APInvoice.refNbr>,
                And<APPayment.docType, Equal<APDocType.prepayment>>>>>>>,
            Where<
                APInvoice.docType, Equal<Optional<APAdjust.adjdDocType>>,
                And2<Where<
                    APInvoice.released, Equal<True>,
                    Or<APInvoice.prebooked, Equal<True>>>,
                And<APInvoice.openDoc, Equal<True>,
                And<APAdjust.adjgRefNbr, IsNull,
                And<APPayment.refNbr, IsNull>>>>>>),Filterable = true)]
        protected virtual void APAdjust_AdjdRefNbr_CacheAttached(PXCache cache)
        {

        }

        #endregion
    }
}

here I made the reference of my project and applied the newly created attribute CustAdjdRefNbr  instead of APInvoice.AdjdRefNbr, now publish the project with these two code files to make the reference number selector display Vendor ID and Name 
 



   

Userlevel 7
Badge +5

@KishoK - Amazing!  Thank you!

Userlevel 7
Badge +5

@KishoK - I have your solution working in 2020R2 but in 2021R1 it doesn’t work.  I made a slight adjustment to the Display Name on the column header to confirm that the overridden attributes are being loaded in the _CacheAttached event. I also recopied the Search2<> BQL command of the APInvoiceType.AdjdRefNbr attribute because it has changed in 2021R1.

I’ve tried adding   [PXMergeAttributes(Method = MergeMethod.Merge)]  but that didn’t to work. 

Any suggestions?

  public class APPayBills_Extension : PXGraphExtension<APPayBills>

  {

      

    //Customer selector field attribute  

    public class CustAdjdRefNbrAttribute : PXSelectorAttribute

    {

      public CustAdjdRefNbrAttribute(Type SearchType)

        : base(SearchType,

        typeof(APRegister.branchID),

        typeof(APRegister.refNbr),

        typeof(APRegister.docDate),

        typeof(APRegister.finPeriodID),

        typeof(APRegister.vendorLocationID),

        typeof(APRegister.curyID),

        typeof(APRegister.curyOrigDocAmt),

        typeof(APRegister.curyDocBal),

        typeof(APRegister.status),

        typeof(APAdjust.APInvoice.dueDate),

        typeof(APAdjust.APInvoice.invoiceNbr),

        typeof(APRegister.docDesc),

        typeof(APRegister.vendorID),

        typeof(APRegister.vendorID_Vendor_acctName),

        typeof(APInvoice.invoiceNbr))

      {

      }



      protected override bool IsReadDeletedSupported => false;

    }      

      

      

    //Override the Reference Nbr. selector attribute with custom selector attribute  

    [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]

    [PXDefault()]

    [PXUIField(DisplayName = "Reference Number", Visibility = PXUIVisibility.Visible)]

    [CustAdjdRefNbr(typeof(Search2<

        APInvoice.refNbr,

        InnerJoin<BAccount,

          On<BAccount.bAccountID, Equal<APInvoice.vendorID>,

          And<Where<

            BAccount.vStatus, Equal<VendorStatus.active>,

            Or<BAccount.vStatus, Equal<VendorStatus.oneTime>>>>>,

        LeftJoin<APAdjust,

           On<APAdjust.adjdDocType, Equal<APInvoice.docType>,

           And<APAdjust.adjdRefNbr, Equal<APInvoice.refNbr>,

           And<APAdjust.released, Equal<False>,

           And<Where<

             APAdjust.adjgDocType, NotEqual<Current<APPayment.docType>>,

             Or<APAdjust.adjgRefNbr, NotEqual<Current<APPayment.refNbr>>>>>>>>,

        LeftJoin<APPayment,

               On<APPayment.docType, Equal<APInvoice.docType>,

               And<APPayment.refNbr, Equal<APInvoice.refNbr>,

               And<APPayment.docType, Equal<APDocType.prepayment>>>>>>>,

        Where<

             APInvoice.docType, Equal<Optional<APAdjust.adjdDocType>>,

             And2<Where<

                APInvoice.released, Equal<True>,

                Or<APInvoice.prebooked, Equal<True>>>,

             And<APInvoice.openDoc, Equal<True>,

             And<APAdjust.adjgRefNbr, IsNull,

             And<APPayment.refNbr, IsNull>>>>>>),

        Filterable = true)]

    protected virtual void APAdjust_AdjdRefNbr_CacheAttached(PXCache cache)

    {

      

    }

}

 

 

Userlevel 2

@ddunn - Wow...seems Acumatica wanted to give hard time to you:laughing:
just joking, In 2021 R1 Acumatica again overrode the attributes in one more graph extension 
called APPayBillsVisibilityRestriction  this is a visibility restriction extension,which is wired with 
the below configuration option (refer pic)
 


 if you disable this configuration your vendor related details will be visible in the selector, if enable those details will be hidden.
So its up to you how you going to handle it, Still you want the Customer and Vendor visiblity restriction need to be enforced and show the vendor details only in the Prepare Payment screen then extend the Primary Graph +  APPayBillsVisibilityRestriction Graph Extension in the manner of
E2 : PXGraphExtension<E1,PrimaryGraph> 
Use the below code 
 public class APPayBills_Extension : PXGraphExtension<APPayBillsVisibilityRestriction, APPayBills>
  {  }

 

Regards

Userlevel 7
Badge +5

Thank you again, @KishoK - you’ve been very helpful in tracking all of this down!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved