Model Object
properties()
Signature
Section titled “Signature”properties() — returns struct
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
returnIncluded | boolean | no | true | Whether to return nested properties or not. |
Examples
Section titled “Examples”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);