Skip to main content
Answer

How to work with Bql for a drop down value

  • October 19, 2023
  • 7 replies
  • 102 views

Forum|alt.badge.img

Any idea to write below SQL query in BQL or in Fbql?
 

SELECT * FROM SOOrder 
where Status ='N' & 'H'

 

Best answer by Naveen Boga

@rashmikamudalinayake10  Here is the BQL Query.

 

If you are using this query in graph extension:

 SOOrder objSOOrder = PXSelect<SOOrder, Where<SOOrder.status, Equal<SOOrderStatus.hold>, And<SOOrder.status, Equal<SOOrderStatus.open>>>>.Select(Base);

 

For your custom graph → Base will not work, you can use this like below.

 

 SOOrder objSOOrder = PXSelect<SOOrder, Where<SOOrder.status, Equal<SOOrderStatus.hold>, And<SOOrder.status, Equal<SOOrderStatus.open>>>>.Select(this);

 

7 replies

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

@rashmikamudalinayake10  Here is the BQL Query.

 

If you are using this query in graph extension:

 SOOrder objSOOrder = PXSelect<SOOrder, Where<SOOrder.status, Equal<SOOrderStatus.hold>, And<SOOrder.status, Equal<SOOrderStatus.open>>>>.Select(Base);

 

For your custom graph → Base will not work, you can use this like below.

 

 SOOrder objSOOrder = PXSelect<SOOrder, Where<SOOrder.status, Equal<SOOrderStatus.hold>, And<SOOrder.status, Equal<SOOrderStatus.open>>>>.Select(this);

 


Forum|alt.badge.img

Thanks!! it worked.

Also, I just tried the same thing by implementing to a PXSelector. Below is the code .but it doesn’t work. btw it worked on getting single value. Something wrong with the query?

[PXSelector
(typeof(Search<SOOrder.orderNbr,
Where<SOOrder.status,
Equal<SOOrderStatus.open>,
And<SOOrder.status,
Equal<SOOrderStatus.hold>>>>))]

This works fine,

[PXSelector
(typeof(Search<SOOrder.status,
Where<SOOrder.status,
Equal<SOOrderStatus.open>>>))]

 


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

@rashmikamudalinayake10  Great, Thanks for sharing the update!!


VardanV
Jr Varsity III
Forum|alt.badge.img+1
  • Jr Varsity III
  • October 20, 2023

In your PXSelector attribute you need to update And<> condition with Or<> to be able to get the more than one record. But my suggestion bellow

 [PXSelector(typeof(Search<SOOrder.orderNbr,Where<SOOrder.status,In3<SOOrderStatus.open, SOOrderStatus.hold>>>))]

 


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

Yes @rashmikamudalinayake10  Please change the Condition to OR instead of AND.

Due to this AND condition system not fetching any records.


Forum|alt.badge.img

Thanks!! it worked.


Forum|alt.badge.img

Correct query for fetching open state and hold state using PXSelector as below

[PXSelector
(typeof(Search<SOOrder.orderNbr,
Where<SOOrder.status,
Equal<SOOrderStatus.open>,
Or<SOOrder.status,
Equal<SOOrderStatus.hold>>>>))]

Note: The above mentioned snippet by vardan22 also work as well.