Adds support for stopping the save operation inside save-record and save-repeatable to be able to perform async tasks like MESSAGEBOX() and REQUEST() and conditionally SAVE() the record at a later point.
The new API consists of PREVENTDEFAULT() and SAVE() used together inside save-record:
ON('save-record', (event) => {
// prevent the save from happening
PREVENTDEFAULT();
const messageParams = {
title: 'Confirm',
message: 'You have selected a critical safety violation. Are you sure?',
buttons: ['Yes', 'No']
};
// start async message box, or any async operation like REQUEST()
MESSAGEBOX(messageParams, (result) => {
if (result.value === 'Yes') {
// save the record now
SAVE();
}
});
});
Why?
It's not possible to present custom warning messages and allow the user to continue. For example, if a user entered a severe defect on an inspection that might cost $1000's to replace, the customer might want to present a confirmation warning on save asking the user if they're sure they meant to enter that.
What?
Adds support for stopping the save operation inside
save-record
andsave-repeatable
to be able to perform async tasks likeMESSAGEBOX()
andREQUEST()
and conditionallySAVE()
the record at a later point.The new API consists of
PREVENTDEFAULT()
andSAVE()
used together insidesave-record
:Why?
It's not possible to present custom warning messages and allow the user to continue. For example, if a user entered a severe defect on an inspection that might cost $1000's to replace, the customer might want to present a confirmation warning on save asking the user if they're sure they meant to enter that.
Testing
Add the above snippet to any form.