Controller
flashDelete()
Signature
Section titled “Signature”flashDelete() — returns any
Available in: controller
Category: Flash Functions
Description
Section titled “Description”The flashDelete() function removes a specific key from the Flash scope. It is useful when you want to delete a particular temporary message or piece of data without clearing the entire Flash. The function returns true if the key existed and was deleted, or false if the key was not present.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | yes | — | The key to delete |
Examples
Section titled “Examples”1. Delete a single flash message
flashDelete(key="errorMessage");
2. Delete another key and check if it existed
if (flashDelete(key="notice")) {
writeOutput("Notice deleted from Flash.");
} else {
writeOutput("Notice key did not exist.");
}
3. Conditional usage before displaying flash
if (structKeyExists(flash(), "warning")) {
warningMsg = flash("warning");
flashDelete(key="warning"); // remove after reading
writeOutput(warningMsg);
}