Skip to main content
Solved

SelectFrom with order by and where part


Forum|alt.badge.img

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;

Best answer by Django

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;

 

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+5
  • Jr Varsity II
  • 237 replies
  • October 13, 2023

Your Where conditions should be before the OrderBy section. 

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

 


Forum|alt.badge.img+6
  • Captain II
  • 554 replies
  • Answer
  • October 13, 2023

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;

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3401 replies
  • October 14, 2023

@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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings