Controller
flashCount()
Signature
Section titled “Signature”flashCount() — returns numeric
Available in: controller
Category: Flash Functions
Description
Section titled “Description”The flashCount() function returns the number of keys currently stored in the Flash scope. This is useful to check whether there are any flash messages or temporary data before attempting to read or display them. It helps in conditionally rendering notifications or determining if the Flash is empty.
Examples
Section titled “Examples”1. Get the number of items in Flash
count = flashCount();
2. Check if there are any flash messages before displaying
if (flashCount() > 0) {
writeOutput("You have " & flashCount() & " messages in Flash.");
}
3. Only display notice if Flash is not empty
if (flashCount() > 0 && structKeyExists(flash(), "notice")) {
writeOutput(flash("notice"));
}