Use the preFormSubmit hook to add custom validation checks or actions.
Parameters #
- mode: 0 = INSERT | 1 = UPDATE | 2 = VIEW
- getColumnValue: getColumnValue(columnName)
-
setValidationError: setValidationError(columnName, errorMessage)
-
unsetValidationError: unsetValidationError(columnName)
Return value #
Return false to cancel submit
Prevent update with custom validation error #
((mode, getColumnValue, setValidationError, unsetValidationError) => {
const error = "Customer 103 cannot be updated!"
const customerNumber = getColumnValue("customerNumber")
if (customerNumber == 103) {
// Set validation error
setValidationError("customerNumber", error)
} else {
// Don't forget to reset!
unsetValidationError("customerNumber")
}
})
Output #
Prevent update with custom behavior #
((mode, getColumnValue, setValidationError, unsetValidationError) => {
const error = "Customer 103 cannot be updated!"
const customerNumber = getColumnValue("customerNumber")
if (customerNumber == 103) {
// Use built-in alert box
wpda.alert("Form submit cancelled", error)
return false
}
})