KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Checking if properties within nested objects and/or collections exist
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 16, 2025

A simple and quick way to check if a property within nested objects and/or collections exist is to check if the expression is Null or not.

For example with the following expression:
$myObject.Prop1.Prop2.Prop3

The existance of Prop3 can be confirmed with the following:

If($myObject.Prop1.Prop2.Prop3#Null)
// Property Exists
Else
// Property Does Not Exist
End if


A caveat of this implementation is that each of the items in the expression must either be a collection, object, or nonexistant. Because the expression uses dot notation, if one of the parts of the expression evaluates to something else like a Text then a syntax error # -10716 will get triggered complaining that an object or collection was expected.

For example the following will trigger the error:
$myObject:=New object("Prop1";"Hello")
If($myObject.Prop1.Prop2.Prop3#Null)