Validating grid values or rows in a TStruct

Generally, in applications, when an invalid value is entered into a cell in a grid, a suitable message should be displayed. The message could be a warning message or an error message.  Follow the steps below to implement the same in Axpert.

Define an expression in the ValidateExpression property of the inputfield to validate a field. The result of the expression should be T (true) if the field value is valid. If the value is invalid, provide a message. This message will be displayed to the user.

Example :

iif(totalexperiencefrom<0,{invalid},{t})

iif(openingdate<date() ,{invalid date},{t})

iif(agefrom<18 ,{invalid input},{t})

Warning message – If the message string is preceded by a minus symbol, the message will be displayed as a warning message. In this case, the message is displayed to the user and Axpert allows the user to enter further data and save the transaction.

Error message – If the message string is not preceded by any minus symbol, the message is displayed to user and the transaction will not be allowed to save.

Clear grid  row for invalid values

Axpert also provides a feature where all the cell values in the row are cleared when invalid values are entered into a cell in the grid.

If the message string is preceded by two minus symbols, the given message will be displayed and all the cell values in the row will be cleared.

Eg. Consider a field with a validate expression as below

iif(Qty>100, {–Quantity should not be greater than 100}, {T})

If user enters more than 100 in the qty field, the message will be displayed and all cell values in the current row will be cleared.

Clearing row if duplicate values are entered

Consider a case where when a user selects or enters a duplicate value in a column, the row should be cleared. This can be done by setting a variable named OnDuplicate_<FieldName>.

If you want to clear the row when a duplicate value is entered in ProductName colum, the variable name should be OnDuplicate_ProductName. The value in this variable can be a message starting with –.

To clear the row when negative values are entered in numeric field use OnNegative_<FieldName>.

To clear the row when a field is left empty use OnEmpty_<FieldName>. These variables can be set in a user defined task that is used in the on form load or on data load event.