Solved

How to limit the data source of a selector?

  • 10 May 2021
  • 4 replies
  • 289 views

Userlevel 6
Badge +5

Hello,

          With other’s help, I was able to add a selector of employees on shipment screen.
I’ve created an employeeclass (Which is referred to VendorClassID in DAC) named “PICKER”,

I’d like to limit the selector only shows the employees from “PICKER”,

I write the below code, but it gives out errors:

 

[PXSelector(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.vendorClassID,Equal<"PICKER">>>),
 typeof(EPEmployee.acctCD), 
typeof(EPEmployee.acctName), 
typeof(EPEmployee.vendorClassID),
SubstituteKey = typeof(EPEmployee.acctCD))]

 

 

       What is the right way to write the codes. Please advise. Thank you.

icon

Best answer by Naveen Boga 10 May 2021, 16:30

View original

4 replies

Userlevel 7
Badge +18

@ray20  Great :) Thanks for sharing the update.

Userlevel 6
Badge +5

@Naveen B @ddunn 
Thank you , experts. Really, really appreciate. Codes are working.

Userlevel 7
Badge +5

The code that you’re looking for is something like this:

#region HelperClasses    

    private class string_PICKER: Constant<string>    

    {

        public string_PICKER():base("PICKER"){}

    }      

#endregion

Then, in your field code you’ll reference that custom class:

Where<EPEmployee.vendorClassID,Equal<class_PICKER>>>),

Now, I typically use the “Convert To Extension” button under the Data Access group to turn the automatically generated code to files under the Code group and that’s where I’d place the code that I wrote above. But I’m not sure where you’d place that code while keeping your code organized in the way that your project currently shows. Other people might be able to help there.

Edit: Naveen has shown you the same thing but done a litte more correctly. :)

Userlevel 7
Badge +18

Hi @ray20 

We can not pass directly that value, and for this, we need to use SQL constants.

Please use the below code and check….

public class SQLConstants

{
 public class PICKER : PX.Data.BQL.BqlString.Constant<PICKER>
        {
            public PICKER() : base("PICKER") { }
        }

}

[PXSelector(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.vendorClassID,Equal<SQLConstants.PICKER>>>),
 typeof(EPEmployee.acctCD), 
typeof(EPEmployee.acctName), 
typeof(EPEmployee.vendorClassID),
SubstituteKey = typeof(EPEmployee.acctCD))]

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