Unofficial Content

Empty as Null Property


Languages: Java, .NET, .NET Mobile, Visual FoxPro, Visual Basic
DBMS: Oracle, SQL Server, DB2 Universal Database, DB2 UDB for iSeries, PostgreSQL, mySQL, Informix, SQL CE
Objects: Transaction


When inserting values in a Transaction Form and a field is left with no value set, should this be considered as a NULL value or as an Empty one?

This ambiguous situation can be solved with the Empty as Null attribute's property. It allows specifying at design time, which "value" (null or empty) will be stored when the user leaves as empty the attribute's control field in the Transaction UI.

Note: For a brief description of how to work with -or avoid- null values in GeneXus-generated applications see Handling Nulls with GeneXus (9.0) .


This Empty as Null property can be set at attribute and/or attribute's control level and specify whether an empty value of the control must be considered as null or not. The possible values are:
  • Yes
  • No
Default value: Yes.

If the property is set at attribute's level, their value is inherited by all controls where the attribute is accepted and it can take the null value; otherwise, the property is ignored.

Setting the property as Yes is equal to specifing the following rule in the Transaction:
Att.SetNull() If Att.IsEmpty()
Note: As you can see, the property Empty as Null does not apply to Business Components.


Imagine the example of Customer and Invoice Transactions. We specify the Empty as Null property in Yes for CustomerId. This property does not apply to the Customer Transaction because CustomerId comprise the primary key and therefore does not allow nulls. However, in the Invoice Transaction the CustomerId can take null value (if Null property = Yes) and if no value is specified in the Transaction form, or the empty one is assigned (i.e. cero if CustomerId is Numeric), the Null will be "stored".

Backward Compatibility

A new property is implemented at KB's level to keep backward compatibility for those Knowledge Bases that come from previous versions of GeneXus Yi. The property is "Empty as Null behavior".
The possible values are:
  • Current Version
  • Version 8.0 and prior (Deprecated)

Default value for new Knowledge Bases: "Current Version"
Default value for converted Knowledge Bases: "Version 8.0 and prior (Deprecated)"

If the property Empty as null behavior is set to Version 8.0 and prior, a new value, Compatible, is also displayed in the Empty as Null attribute/control property. This is the default value if the Knowledge Base comes from previous versions to ensure the compatibility.

What does the "Compatible" value means?
Until GeneXus 8.0, when the user has left the attribute field without values in the Transaction form, the empty value were inserted. So, this is the behavior in the case of the "Compatible" property value.

IMPORTANT: If you are converting the KB from 8.0 or previous, we recommend changing the Compatible value to one of the Yes/No values in a gradual migration process.

Comments & Collaboration