Update custom fields through Customization Plugin

By | October 23, 2023

Acumatica is a powerful cloud-based ERP system known for its flexibility and extensibility. It allows businesses to tailor the software to their unique needs through a variety of customization options. One of the most versatile tools at your disposal is the Customization Plugin. In this blog post, we will take you through the process of creating and using a Customization Plugin in Acumatica using the Customization Editor.

A Customization Plugin is a piece of code that you can use to extend and enhance the functionality of Acumatica ERP. It enables you to update the custom fields in the database while publishing customization.

Sometimes, we encounter a situation where we have already included custom fields in the customization, and these fields are saved to the database. We want to set default values for these fields in Acumatica. In such cases, we can make use of Acumatica’s customization plugin feature.

Here, I’ve added a custom decimal field that, by default, saves as NULL in the database. However, when we attempt to display these custom fields in a GI (Generic Inquiry), the values appear as blank. Our goal is to have them displayed as ‘0.0’ instead.

01.png

Navigate to the Customization Editor and select the “Code” section. Then, add a new code file.

Note: Make sure to choose the “Customization Plugin” as the file template.

02.png

After clicking the “OK” button, a code file is generated in the code section with predefined methods:

  1. OnPublished : This is the point where you can access the file system and perform necessary configurations before the application restarts.
  2. UpdateDatabase : At this stage, you can include operations that need to be executed to ensure your own database update scripts are applied.

In our example, we want to update the database, so simply add the following lines to the “Update Database” method.

Code Snippet :

PXDatabase.Update

(new PXDataFieldAssign(PXDbType.Decimal, 0, 0),
new PXDataFieldRestrict(PXDbType.Decimal, 0, null, PXComp.ISNULL));

This will ensure that your desired database updates are applied as needed.

After adding the code to the Customization Plugin’s UpdateDatabase() method, simply publish the project. The result will be as follows:

03-1.png

Upon completion, all the decimal values that were previously NULL will be converted to 0.0 values. These values will also be displayed in the Generic Inquiry (GI) as expected.

Greytrix, with its 24+ years of expertise as the Sage Development partner, extends its mastery to bring Acumatica to modern businesses. Greytrix offers complete end-to-end professional services for Acumatica, ranging from development, support, technical assistance, consulting, and system integrations.