Solved

Cannot find the PXSelect to override in the source code for the Vendor ID

  • 4 February 2022
  • 6 replies
  • 400 views

Userlevel 6
Badge +3

I want to add the State to the Vendor ID lookup popup window (selector).  It is not one of the fields that can be added easily as it is not part of the vendor id attribute.

There is a well documented way to do this here, but unfortunately, I cannot find where the actual PXSelect statement is to overriden.

I found the VendorAttribute which matches the fields that show in the popup window.

I thought maybe this method might be what is used to create the results for the selector but when I put a break on this in debug, it is not being fired.

 

In the customization editor on screen AP301000 Bills and Adjustments, the field attribute is shown as follows. 

Does anyone know where the actual PXSelect statement is for this lookup field?  The code example provided by KishoK in the article mentioned above gives me a boilerplate template on how to do it, I just don’t know where to override the PXSelect that is being used for the popup.

Thanks,

Joe

icon

Best answer by Naveen Boga 7 February 2022, 09:13

View original

6 replies

Userlevel 7
Badge +17

Hi @joe21  I have not tested the below code but it may work. Please verify.

 [PXMergeAttributes(Method = MergeMethod.Merge)]
[PXUIField(DisplayName = "Vendor ID")]
[PXDimensionSelector("BIZACCT",
typeof(Search2<BAccountR.bAccountID,
LeftJoin<BAccount2, On<BAccount.parentBAccountID, Equal<BAccount2.bAccountID>>,
LeftJoin<Contact, On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>,
LeftJoin<Address, On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>>>>,
Where<Current<BAccount.bAccountID>, NotEqual<BAccountR.bAccountID>,
And<BAccountR.type, Equal<BAccountType.vendorType>>>>),
typeof(BAccountR.acctCD),
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(BAccountR.type),
typeof(BAccount.parentBAccountID),
typeof(BAccount2.acctName),
typeof(BAccountR.classID),
typeof(BAccountR.status),
typeof(Contact.phone1),

typeof(Address.addressLine1),
typeof(Address.city),
typeof(Address.state),
typeof(Address.countryID),
typeof(Address.postalCode),
typeof(Address.countryID),
typeof(Contact.eMail),
DescriptionField = typeof(BAccountR.acctName))]
protected virtual void POOrder_VendorID_CacheAttached(PXCache sender)
{
}

 

 

 

Userlevel 6
Badge +3

Hi @Naveen B.  I copied your code.  I changed POOrder_VendorID_CacheAttached to APInvoice_VendorID_CacheAttached because I am working on the Bills and Adjustments screen.  The popup now includes the extra fields due to your magic code!

However, when I select a Vendor from the Popup, I get an overflow exception.  I made a snip of the error.  I am not sure, but maybe the tstamp field is not populated and is causing an error?

That’s just a guess because it says something about value cannot be null.

FYI, the method is located in the DimensionAttribute.cs file under this class:

SO CLOSE!  :-)

Userlevel 6
Badge +3

I tried going about this the way that KishoK described.  I created a custom attribute

    public class CustVendorIDAttribute : PXSelectorAttribute
    {
        public CustVendorIDAttribute(Type search)
                 : base(search,
                    typeof(Vendor.acctCD), 
                    typeof(Vendor.acctName),
                    typeof(Address.addressLine1), 
                    typeof(Address.addressLine2), 
                    typeof(Address.state),
                    typeof(Address.postalCode),
                    typeof(Contact.phone1), 
                    typeof(Address.city), 
                    typeof(Address.countryID),
                    typeof(Vendor.curyID),
                    typeof(Contact.attention),
                    typeof(Vendor.vendorClassID), 
                    typeof(Vendor.status))
        {
        }
    }

Then in my extension, I created a selector using the custom attribute 

        [PXDBString(15, IsKey = true, IsUnicode = true)]
        [PXDefault()]
        [PXUIField(DisplayName = "Vendor ID", Visibility = PXUIVisibility.Visible)]
        [CustVendorIDAttribute(typeof(Search2<BAccountR.bAccountID,
            LeftJoin<BAccount2, On<BAccount.parentBAccountID, Equal<BAccount2.bAccountID>>,
            LeftJoin<Vendor, On<Vendor.bAccountID, Equal<BAccountR.bAccountID>>,
            LeftJoin<Contact, On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>,
            LeftJoin<Address, On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>>>>>,
            Where<Current<BAccount.bAccountID>, NotEqual<BAccountR.bAccountID>,
            And<BAccountR.type, Equal<BAccountType.vendorType>>>>), Filterable = true)]
        protected virtual void APInvoice_VendorID_CacheAttached(PXCache sender)
        {
        }

The popup looks perfect.  But when I select a vendor from the popup, I get this error:

 

I’m fumbling in the dark trying various things.  Both ways get the popup to give me the fields I want but when I select the vendor, I get an error.  

@Naveen B , your way works but causes an overflow exception and the KishoK way gives me an invalid column name error.

I feel that this is so close to working, it hurts.

 

Userlevel 2

Hi Joe 
Hope you’re doing great,  I saw your message and gone through this case 
you’re almost close but I have rather an easy approach. 
When I was checking the Vendor Active attribute I found it derived from VendorAttribute 
while checking the code of VendorAttribute voila it has a constructor (typeof(Search)): base(Search, types[]) signature, So we can utilize it 
check the below code
I'm going to create our version of the VendorActive attribute (CustVendorActive) with slight modification 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using PX.Common;
using PX.Data;

using PX.Objects.GL;
using PX.Objects.TX;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.CS;
using PX.Objects.CR;
using APQuickCheck = PX.Objects.AP.Standalone.APQuickCheck;
using PX.Data.SQLTree;
using PX.Objects.GL.FinPeriods;
using PX.Objects.PO;
using PX.Objects.GL.FinPeriods.TableDefinition;
using PX.Data.BQL;


namespace PX.Objects.AP
{
[PXDBInt()]
[PXUIField(DisplayName = "Vendor", Visibility = PXUIVisibility.Visible)]
[PXRestrictor(typeof(Where<Vendor.vStatus, Equal<VendorStatus.active>,
Or<Vendor.vStatus, Equal<VendorStatus.oneTime>>>), Messages.VendorIsInStatus, typeof(Vendor.vStatus))]
public class CustVendorActiveAttribute : VendorAttribute
{
public CustVendorActiveAttribute(Type search)
: base(search, typeof(Vendor.acctCD), typeof(Vendor.acctName),
typeof(Address.addressLine1), typeof(Address.addressLine2), typeof(Address.postalCode),
typeof(Contact.phone1), typeof(Address.city), typeof(Address.countryID), typeof(Address.state),
typeof(Location.taxRegistrationID), typeof(Vendor.curyID),
typeof(Contact.attention),
typeof(Vendor.vendorClassID), typeof(Vendor.vStatus))
{
}

public CustVendorActiveAttribute()
: base()
{
}
}
}

Here note I’m passing my own set of the fields list to the first constructor 
To invoke the attribute please check the graph extension → cache attached code attached below  
 

 [CustVendorActive(typeof(Search<BAccountR.bAccountID>),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Vendor.acctName),
CacheGlobal = true,
Filterable = true)]
[PXDefault]
//[PXForeignReference(typeof(Field<APRegister.vendorID>.IsRelatedTo<BAccount.bAccountID>))]
protected virtual void APInvoice_VendorID_CacheAttached(PXCache cache)
{

}

You need to pass the search condition (Search<BAccountR.bAccountID>) here to invoke the base constructor which has the same signature.
Please let us know if it solves your requirement 
 

Userlevel 7
Badge +17

Hi, @joe21  and @KishoK  I think it is NOT required to create a new custom version of the “Vendor Attribute” code for this requirement.

We can use PXCustomizeSelectorColumns concept to add the fields to the existing selector if that particular table is already in the Base code.

In this case, the Address table is already there in the VendorActive Attribute, we can PXCustomizeSelectorColumns feature to add the State field.

 

Here is the below simple code and it is working as expected. Please find the source code and screenshot for reference.

 public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXUIField(DisplayName = "Vendor ID")]
[PXCustomizeSelectorColumns(
typeof(Vendor.acctCD),
typeof(Vendor.acctName),
typeof(Address.addressLine1),
typeof(Address.addressLine2),
typeof(Address.postalCode),
typeof(Contact.phone1),
typeof(Address.city),
typeof(Address.state), // Here is the code for STATE field
typeof(Address.countryID),
typeof(Location.taxRegistrationID),
typeof(Vendor.curyID),
typeof(Contact.attention),
typeof(Vendor.vendorClassID),
typeof(Vendor.status))]

protected virtual void APInvoice_VendorID_CacheAttached(PXCache sender)
{
}
}

 

 

Hope this helps!!

Userlevel 6
Badge +3

Hi Kisho and Naveen, 

Thank you both for solutions to my issue.  I don’t know which one to mark as best answer and they both are awesome.  I have learned much from this issue and BOTH of your solutions are very valuable.

Cheers friends.

Joe Schmucker

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