Skip to content

Model Object

setProperties()

setProperties() — returns void

Available in: model Category: Miscellaneous Functions

Allows you to set all the properties of an object at once by passing in a structure with keys matching the property names.

NameTypeRequiredDefaultDescription
propertiesstructno[runtime expression]The properties you want to set on the object (can also be passed in as named arguments).
// 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();