PREVENTDEFAULT

Prevents the save operation from finishing in the record editor. This function can be used inside save-record or save-repeatable to halt the save operation. Use this in combination with MESSAGEBOX() and ALERT() to display custom warning messages when the user saves a record.

Description

PREVENTDEFAULT is used to implement custom warning messages when saving records. For example, displaying a custom confirmation message to the user when a special condition is met within the record to confirm that the user intends to save. It can be used as an extra layer of exception handling to present custom messages or make custom HTTP requests within the save process.

Example Data Event

ON('save-record', () => {
  if (CHOICEVALUE($damage) === 'Critical') {
    PREVENTDEFAULT();

    const messageParams = {
      title: 'Confirm',
      message: 'You have selected a critical safety violation. Are you sure?',
      buttons: ['Yes', 'No']
    };

    MESSAGEBOX(messageParams, (result) => {
      if (result.value === 'Yes') {
        SAVE();
      }
    });
  }
});