Solved

SelectFrom with order by and where part

  • 13 October 2023
  • 3 replies
  • 47 views

Userlevel 3
Badge

Hi Team,

Need know how to write bql query with order by and where part. Can someone help me?

My Sample

[PXFilterable]
        public SelectFrom<HMRCVendorRegisterDetail>.OrderBy<Desc<HMRCVendorRegisterDetail.validTo>>.Where<HMRCVendorFilter.bAccountID.FromCurrent.IsNull.Or<HMRCVendorRegisterDetail.bAccountID.IsEqual<HMRCVendorFilter.bAccountID.FromCurrent>>>.View.ReadOnly DetailsView;

icon

Best answer by Django 13 October 2023, 16:40

View original

3 replies

Userlevel 6
Badge +5

Your Where conditions should be before the OrderBy section. 

SelectFrom<Table>.Where<WhereConditions>.OrderBy<Desc<Table.Field>>.View.ReadOnly DetailsView;

 

Userlevel 7
Badge +5

I searched through the Acumatica code for .OrderBy< and found this example:

public SelectFrom<ContactAccount>
.Where<
ContactAccount.bAccountID.IsEqual<CRLead.bAccountID.FromCurrent>
.And<ContactAccount.contactType.IsEqual<ContactTypesAttribute.person>>
>
.OrderBy<
ContactAccount.isPrimary.Desc,
ContactAccount.displayName.Asc
>
.View Link_SelectEntityForLink;

 

Userlevel 7
Badge +17

@bhagyat25  Below is the query for your query and hope this helps!!

 

        public PXSelect<HMRCVendorRegisterDetail,Where<HMRCVendorFilter.bAccountID, IsNull, Or<HMRCVendorRegisterDetail.bAccountID, Equal<Current<HMRCVendorFilter.bAccountID>>>>,
OrderBy<Desc<HMRCVendorRegisterDetail.validTo>> DetailsView;

 

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