Scroll Top

Min & Max values configuration in ADempiere

Getting your Trinity Audio player ready...

Problem Statement:

In any Business Application, we will have common need to validate the input data. One of the common and most used validation is range validation i.e. input data must be with in specified range.  In ADempiere we fulfill this requirement by writing one callout funtion for each field.

If there is a way we can do these validation with simple configuration changes then we can save lot of development effort and functional consultant can change range dynamically as per the need. ADempiere does not have this feature inbuilt, but with minor code changes we can achieve this.

Scope of Article:

As a part of this Article, we will be cover following topics

  • How range validation works
  • Changes we need to make in ADempiere to support range validation for Quantity,Number,Amount,Integer,Date Reference types in ADempiere.

Prerequisites:

  • Need to have basic knowledge on ADempiere window creation with validations.
  • Java SE knowledge is required.

Technology :

  • Adempiere 342 or above

Current Behavior :

  • By default ADempiere doesn’t support Min & Max values validations.We need to make code changes to have validations in place.
  • Without making any code changes, following are the test cases of Min & Max values functionality in default ADempiere.

Min & Max values configuration for Date
By login with System/SystemAdministrator, configure Min & Max Date(Date Format : yyyy/MM/dd) values for Account Date of  M_InOut in Table and Column.Now test this Min & Max configuration of Account Date in Shipment ( Customer ) window.

Max Value Testing :
Entered 26/09/2016 in Account Date field, But there is no Max Value validation error.Min Value Testing :

Entered 26/09/2008 in Account Date field, But there is no Min Value validation error.Min & Max values configuration for Integer ( Reference Type )

Configure Min & Max values for No Packages Integer field of M_InOut in Table and Column.Now test this Min & Max configuration of No Packages field in Shipment ( Customer ) window.

Max Value Testing :
Entered 35 in No Packages field, But there is no Max Value validation error.Min Value Testing :

Entered 2 in No Packages field, But there is no Min Value validation error.To support Min & Max values configuration, we need to make code changes.

Changes Details :

  • Added following new Callout file ( CalloutTable.java) to check the validations and raise validaton errors.

  • Made following changes in EagleConstants.java ( In this file, we have declared the all required constants ).

  • Made following changes in ADTabPanel.java

  • Added following new Methods in ADTabPanel.java

  • Made following changes in dataStatusChanged(DataStatusEvent e) method of ADTabPanel.java

  • Added below methods in org.wtc.util.WTCUtil.Java

  • Associate newly created Callout to MinValue and MaxValue columns of AD_Column Table by executing following update statements in database.

  • And create following required messages in AD_Message table to show validation error messages.
  • After making  above changes, Test the same scenarios to check Min & Max validations.

Max Account Date validation testing
Entered 10/10/2014 in Account Date field and see the error message.Min Account Date validation testing.

Entered 26/09/2010 in Account Date field and see the error message.Max No Packages validation testing.

Entered 12 in No Packages field and see the error message.Min No Packages validation testing.

Entered 2 in No Packages field and see the error message.We are also supporting Quantity,Number,Amount Reference Types to check their min and max values and raise validation messages.

Limitation : Whenever model(MInOut.java) new instance is created in the code and saved, in this case validations doesn’t work, they will work only when data is entered through window.

Summary:

As a part of this article we come to know what are the necessary changes, we need to do to have min and max values validations for specific fields in ADempiere. Hope you have enjoyed reading this article.

Walking Tree promotes ADempiere and we support the users as well as the developers to ensure that the business is able to take complete advantage of ADempiere’s wonderful capability. In case you are looking for a professional assistance then do visit our website to get in touch with us.

References:

  • http://www.adempiere.com/Callout
  • http://www.adempiere.com/Development

Leave a comment

Privacy Preferences
When you visit our website, it may store information through your browser from specific services, usually in form of cookies. Here you can change your privacy preferences. Please note that blocking some types of cookies may impact your experience on our website and the services we offer.