Custom Selector Attribute

Hi All,

Today I want to discuss with you a ways to define selectors and data for them.

define selectors and data for them in acumatica

Usually you define selectors like this:


In this case system will automatically select value from database Carrier table and show list of Carrier IDs to user.
In this case you have 2 potential problems:

  • you should have a database table, otherwise you will see an error.
  • There is no way to dynamically change or adjust data that is returned to user
  • You can limited configurations to control selector behavior.

To solve these problem Acumatica has a Custom Selector attributes:

public class CustomerPriceClassAttribute : PXCustomSelectorAttribute
    public CustomerPriceClassAttribute()
        : base(typeof(ARPriceClass.priceClassID))
            this.DescriptionField = typeof(ARPriceClass.description);
    protected virtual IEnumerable GetRecords()
        foreach (ARPriceClass pc in PXSelect<ARPriceClass>.Select(this._Graph))
            yield return pc;

In this case you see that you have simple attribute, that is really similar to the attribute for first example. Using GetRecords method you can create a custom BQL querry, select any data you want, apply any filter and return it as a IEnumberble collection.
In the user interface you will see exactly data provided by your custom query.

Some tips and Ideas:

  1. In the GetRecords method you can return data that does not exists in the database.
  2. Acumatica works with GetRecords delegate absolutely the same way how it works with data view delegate, this means that you may use all the same tricks there. For example if you return nothing or you method is void, you can modify base view using WhereAnd, WhereOr, WhereNew and other methods. To get base view use PXView.View;
  3. You also can override DescriptionFieldSelecting event to control what value will be returned back as a description of current record.
  4. All standard selector configuration properties can be configured through custom selector constructor.

Integration services provider custom selector attribute:

Company custom selector attribute:

Have a nice development!

1 Reply to “Custom Selector Attribute”

  1. Thanks. Good write-up. I wish GetRecords() method was declared in the base PXCustomSelectorAttribute class as protected. So all we had to do it to override it. Similarly, to the template method DP.

Leave a Reply

Your email address will not be published. Required fields are marked *