Skip to content

Model Configuration

afterCreate()

afterCreate() — returns void

Available in: model Category: Callback Functions

Registers method(s) that should be called after a new object is created.

NameTypeRequiredDefaultDescription
methodsstringno—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).
// 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");