Runtime and Constant Dropdown List in Acumatica ERP

Vachagan Mirzoian
4 min readDec 4, 2022

The UI of any website can contain a dropdown lists. The values shown on UI pages can be constantly predefined or generated during runtime. The same takes a place in Acumatica ERP system.

As we know the backbone of any Acumatica project are Data Access Class, Business Logic Controller or Graph and the corresponding ASPX Screen. This concept reminds the ASP.NET MVC. Each DAC contains fields holding or representing a value. As in Acumatica, in general, the concepts of attributes, generics, reflection and event are widely used for everything, the conversion of simple field into a dropdown one is achieved by using attributes. Let’s look at the example of a DAC.

Data Access Class

To be brief, each Acumatica DAC class must implement IBqlTable interface. The class not mandatorily can contain a Primary and Foreign Key declarations. Each field consists of 2 components, class field and property field. And finally, the property field in most cases must be decorated by at least one of data type attributes and PXUIField attribute. More details can be found in Acumatica Framework Development Guide (page 236).

Business Logic Controller

Ths code showed the graph core functionality. At first the class is inherited from PXGraph<T> generic class, where the T type parameter is the declared class itself. Besides regular methods, the class contains Acumatica graph-specific elements, Selects and Event Handlers. More details can be found in Acumatica Framework Development Guide (page 19).

Screen

Here we see the typical ASP.NET code. For information look at Essential ASP.NET Web Forms Development, Full Stack Programming with C#, SQL, Ajax, and JavaScript Capter 4.

Now let’s investigate the steps required to create runtime dropdown lists in Acumatica.

As each kind of field has corresponding Attribute, for dropdown list field PXStringListAttribute can be used. Depending on data we want to save in database, PXIntListAttribute, PXDecimalListAttribute and etc. can be used.

The values required to be shown on the screen, can be directly given to attribute as array arguments. Dropdown list is formed by 2 components, labels and UI values.

The final result is this.

For more flexibility we can use another approach.

We declare a class derived from PXStringListAttribute class. We “unify” the values using Pair() mehtod and giving the values to base class. Then we use our customly created BZListAttribute class on the field. The result on screen is the same.

To retrieve data at runtime, we use the C# concept of reflection. In this case we do not give any string to DAC’s field attribute. The value would be extracted from compiled code instead. It is important to have PXStringList attribute with null array. The presence of this attribute is mandatory because it is the only way to tell to Acumatica about visual appearance of a field on screen ASPX level. We would have simple text input field if we do not use PXStringList attribute or any of its derived classes. Besides that, to interact with Acumatica fields, we use event handlers. So, to change the field values, we call generic SetList<Field>() method of PXStringList attribute inside RowSelected event handler. The method takes 4 arguments:

1. DAC cache,

2. DAC row,

3. Labels,

4. UI Values

For first, we have simple JSON data-based models to be used for REST API requests. These fields and attributes would be retrieved and shown on screen tab columns as dropdown lists.

Here we want to show the model’s field property name and field’s attribute’s input string value on screen for further use. Here is the complete code of required logic.

On Acumatica screen, as Data field column values we want to show the model’s properties. To do that we create an object of data model class. Then we find its type and read the type’s internal content by simple LINQ commands. That content is stored in 2 Lists which then are given to SetList<Field>() method.

For Field Name or Key column, we show the attribute’s input strings. We find the class properties and store them as an array. Then for each of property element of array, we find the element’s name. The array of names is stored in Lists. The lists are converted into arrays before being used as method arguments.

The final result of the code is this.

Used Recourses

1. Acumatica Framework Development Guide — http://acumatica-builds.s3.amazonaws.com/builds/22.2/PDF/AcumaticaERP_FrameworkDevelopmentGuide.pdf

2. Essential ASP.NET Web Forms Development, Full Stack Programming with C#, SQL, Ajax, and JavaScript

Contact me on LinkedIn, Instagram, TikTok and Facebook.

--

--