Solved

PXSelector with where condition

  • 26 September 2023
  • 2 replies
  • 136 views

Userlevel 3
Badge

Need to filter out vendor codes from BAccount DAC. Now it is loading all the BAccounts.

#region VendorID       
        [PXUIField(DisplayName = "Vendor", Required = true)]
        [PXDBDefault(typeof(BAccount.bAccountID))]
        [PXSelector(typeof(Search<BAccount.bAccountID>),
                    typeof(BAccount.acctCD),
                    typeof(BAccount.acctName),

        SubstituteKey = typeof(BAccount.acctCD),
        DescriptionField = typeof(BAccount.acctName))]
        public virtual int? BAccountID { get; set; }
        public abstract class bAccountID : PX.Data.BQL.BqlInt.Field<bAccountID> { }
        #endregion

icon

Best answer by Naveen Boga 26 September 2023, 15:55

View original

2 replies

Userlevel 7
Badge +19

@bhagyat25  Please try with the below code.

 

 #region VendorID       
        [PXUIField(DisplayName = "Vendor", Required = true)]
        [PXDBDefault(typeof(BAccount.bAccountID))]
        [PXSelector(typeof(Search<BAccount.bAccountID,Where<BAccount.type,Equal<BAccountType.vendorType>>>),
                    typeof(BAccount.acctCD),
                    typeof(BAccount.acctName),

        SubstituteKey = typeof(BAccount.acctCD),
        DescriptionField = typeof(BAccount.acctName))]
        public virtual int? BAccountID { get; set; }
        public abstract class bAccountID : PX.Data.BQL.BqlInt.Field<bAccountID> { }
        #endregion

Badge +12

This is how it would be written in F-bql:

[PXSelector(typeof(SearchFor<BAccount.bAccountID>.
In<SelectFrom<BAccount>.
Where<*your_conditions*>>),
typeof(BAccount.acctCD),
typeof(BAccount.acctName),
SubstituteKey = typeof(BAccount.acctCD),
DescriptionField = typeof(BAccount.acctName))]

However, if you’re looking for Vendors, it would be better to query from the Vendor table directly, as not all BAccounts will be Vendors, obviously.

Acumatica also provides some selector attributes out of the box which would probably save you some time writing a selector yourself, for instance [VendorRaw] or [VendorActive].

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