On Cancel
Last updated 26/03/2026
Overview
The On Cancel event is a client-side event that executes when the user clicks the Cancel button on a form. This occurs when a user discards any unsaved changes and exits the current edit or add mode, allowing the application to respond before the form reverts to its previous state.
How it Works
When the Cancel button is clicked:
- The form exits edit or add mode.
- Any unsaved changes are discarded on the client.
- The On Cancel client-side event executes.
Use Cases
- Confirm with the user before discarding changes
- Reset temporary variables or UI state
- Track when a user cancels editing
- Clean up any client-side data or calculations
Example
This function executes when the Cancel button is clicked, it displays an alert and clears the temporary variable used during editing.
Clear temporary state on cancel
function onCancelEvent(five, context, result) {
five.setVariable('RecordOnEditTimeStamp', null);
five.alert('Changes have been discarded');
return five.success(result);
}