Skip to content

Model Object

properties()

properties() — returns struct

Available in: model Category: Miscellaneous Functions

Returns a structure containing all the properties of a model object, where the keys are the property (column) names and the values are the current values for that object. This is useful when you want to inspect all the attributes of a record at once, serialize data, or debug object state. By default, properties() includes nested or associated properties (such as related objects). You can control this behavior using the returnIncluded argument to exclude them if you only want the direct properties of the object.

NameTypeRequiredDefaultDescription
returnIncludedbooleannotrueWhether to return nested properties or not.
1. Get all properties for a user object
user = model("user").findByKey(1);
props = user.properties();

2. Exclude nested/associated properties
user = model("user").findByKey(1);
props = user.properties(returnIncluded=false);

3. Iterate through properties
user = model("user").findByKey(2);
props = user.properties();
for (key in props) {
    writeOutput("#key#: #props[key]#<br>");
}

4. Convert properties to JSON for API output
user = model("user").findByKey(3);
props = user.properties(returnIncluded=false);
jsonData = serializeJSON(props);