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.

About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data MigrationIntegrated App developmentCustom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.