Model Object
setProperties()
Signature
Section titled “Signature”setProperties() — returns void
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Allows you to set all the properties of an object at once by passing in a structure with keys matching the property names.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
properties | struct | no | [runtime expression] | The properties you want to set on the object (can also be passed in as named arguments). |
Examples
Section titled “Examples”// 1. Update properties from a form post struct
user = model("User").findByKey(1);
user.setProperties(params.user);
// 2. Pass a struct literal directly to set multiple properties at once
user = model("User").findByKey(1);
user.setProperties({firstName: "Jane", lastName: "Doe", email: "jane@example.com"});
user.save();
// 3. Use named arguments instead of a struct (named args are merged with the properties struct)
user = model("User").findByKey(1);
user.setProperties(firstName="John", lastName="Smith");
user.save();