Wednesday, 7 October 2015

How to Customize Selector in Acumatica

Hi Everyone,

Sometimes you want to add additional selector column to the screen, but this process not always is super strait forward.
Acumatica Selector
I will try to guide you step by step, how to add additional address line column to location selector on Sales Orders Screen.

First of all lets create a new customization try to analyse this selector control.
If you select this field and check attributes, that you can can see that there is no selector attribute, but we have strange LocationIDAttribute. Actually selector is there, but it is hidden by LocationIDAttribute. Sometimes to accumulate some logic in one attribute, Acumatica developers uses special types attributes - PXAccumulatorAttribute. This attribute has a collection of other attributes inside. During runtime, Acumatica framework will check that our attribute is inherited from Accumulator and will add all nested attributes in the PXCache.

In this code you can see that PXDimensionSelectorAttribute (that is real selector attribute) is added to protected collection on all attributes.
LocationID Attribute inheritance flow:Acumatica Selector Attributes Inheritance
Ok, but how to customize selector columns? And here Acumaita frameworks, starting from version 5.0 has super nice feature - additional attribute that will customize selector columns even if selector is nested. Just specify PXCustomizeSelectorColumns and define columns that yoг want to see.
You can add this attribute manually, or using visual designers. Do the following:
  1. Select required field in DAC customization window.
  2. Click Selector Columns
  3. In this popup panel you will see all current selector columns
  4. Click Add Columns
  5. Here you will see all available columns for this selector.
  6. Try to filter columns by "Address"
Acumatica Customization Browser for Selectors
Actually, there is no any address in the list of available columns, except Default Address - this is a link to another DAC, that holds address information.
So we have to add a join condition from our selector to address table using this field. Please, refer to where we have a source code of LocationIDBase Atrribute and notice there an additional constructor parameter - JoinType.

Lest just customize the LocationID attribute with additional Join condition and lets add PXCustomizeSelectorColumns  with address field as well.
Acumatica Customization Browser

There result customization code is here:

Now you can just publish the customization and use your new super nice user interface.


Ben Rothe said...

Thank you for your blog on how to customize the Location selector.

I am trying to do something similar for the Customer selector on the Sales Order screen. Specifically, I would like to show the address fields (addressLine1, city, state, etc.) associated with the defBillAddressID instead of the main customer address.

The customer selector uses a [CustomerActive] attribute, but I haven't been able to figure out how to add a join condition to allow me to access the billing address fields. Any ideas or tips?

Sergey Marenich said...

Hi Ben,

Try this approach please
#region CustomerID
[CustomerActive(typeof(Search, Equal,
typeof(Customer.acctCD), typeof(Customer.acctName), typeof(Customer.acctReferenceNbr),
typeof(Address.addressLine1), typeof(Address.addressLine2), typeof(Address.postalCode),
typeof(Contact.phone1), typeof(, typeof(Address.countryID),
typeof(Location.taxRegistrationID), typeof(Customer.curyID),
typeof(Customer.customerClassID), typeof(Customer.status),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Customer.acctName), Filterable = true)]
public int? CustomerID { get; set; }