Model Configuration
afterCreate()
Signature
Section titled “Signature”afterCreate() — returns void
Available in: model
Category: Callback Functions
Description
Section titled “Description”Registers method(s) that should be called after a new object is created.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
methods | string | no | — | Method name or list of method names that should be called when this callback event occurs in an object’s life cycle (can also be called with the method argument). |
Examples
Section titled “Examples”// 1. Register a single method to run after an object is created
// In models/User.cfc
component extends="Model" {
function config() {
afterCreate("sendWelcomeEmail");
}
private function sendWelcomeEmail() {
// send email to this.email
}
}
// 2. Register multiple methods by passing a comma-delimited list
afterCreate("updateCache,notifyAdmin");
// 3. Register using the named `methods` argument
afterCreate(methods="syncToExternalApi");