Skip to main content
Solved

PXSelector static where clause

  • September 13, 2021
  • 3 replies
  • 1033 views

I have added a field to the existing SOOrder DAC in order to carry a ReasonCode.. But I only want to select records from the ReasonCode where the Usage field is equal to ‘A’

Here is my selector code to display the ReasonCodeID and Descr fields..

[PXSelector(typeof(Search<ReasonCode.reasonCodeID, Where<ReasonCode.usage, Equal<'A'>>>), typeof(ReasonCode.reasonCodeID), typeof(ReasonCode.descr))]
 

 

But this is the error:

\App_RuntimeCode\PX_Objects_SO_SOOrder_extensions.cs(36): error CS1031: Type expected

Best answer by Gabriel Michaud

Hi @ryanmoon32,

You cannot include scalar values directly in BQL queries. You need to use a constant class, like this one:

public class myConstant : Constant<string> { public myConstant() : base(“A”) { } }

It just so happens there’s already a set of constants defined for reason code usage in the ReasonCodeUsages class; you don’t need to redefine it. Here’s how it should look:

[PXSelector(typeof(Search<ReasonCode.reasonCodeID, Where<ReasonCode.usage, Equal<ReasonCodeUsages.adjustment>>>), typeof(ReasonCode.reasonCodeID), typeof(ReasonCode.descr))]

 

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

3 replies

Gabriel Michaud
Captain II
Forum|alt.badge.img+11

Hi @ryanmoon32,

You cannot include scalar values directly in BQL queries. You need to use a constant class, like this one:

public class myConstant : Constant<string> { public myConstant() : base(“A”) { } }

It just so happens there’s already a set of constants defined for reason code usage in the ReasonCodeUsages class; you don’t need to redefine it. Here’s how it should look:

[PXSelector(typeof(Search<ReasonCode.reasonCodeID, Where<ReasonCode.usage, Equal<ReasonCodeUsages.adjustment>>>), typeof(ReasonCode.reasonCodeID), typeof(ReasonCode.descr))]

 


  • Author
  • Freshman I
  • 10 replies
  • September 13, 2021

Thanks @Gabriel Michaud 
For future reference, where would that class for the constant go inside of my customization project?

Code - Create Code File - New Graph or Code File?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • September 14, 2021

Hi @ryanmoon32  Yes.

As per standard practice, you need to create the separate class file (Constants.cs), where you can maintain all constants of your project and access it from here.


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