Solved

PXSelector static where clause

  • 13 September 2021
  • 3 replies
  • 26 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
icon

Best answer by Gabriel Michaud 13 September 2021, 22:48

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

3 replies

Userlevel 6
Badge +7

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

 

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?

Userlevel 6
Badge +9

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


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 — 2020  Acumatica, Inc. All rights reserved