Skip to main content

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

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:

aPXSelector(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?


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