Skip to main content
Solved

PXSelector with where condition

  • 26 September 2023
  • 2 replies
  • 154 views

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))]
        rPXSelector(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

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