Skip to main content
Solved

PXSelector with where condition

  • September 26, 2023
  • 2 replies
  • 603 views
  • Translate All

Forum|alt.badge.img

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

Best answer by Naveen Boga

@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

View original

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • September 26, 2023

@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

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

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].

Translate