Sc_error_exit() not working in onBeforeInsert

Hi,

According to the official Scriptcase documentation I try to use sc_error_exit() in the onBeforeInsert event of a form. But the macro doesn’t stop the processing of the insert and proceeds with the insertion. For troubleshooting purposes, I have put sc_error_message(‘Message me something’) in the onAfterInsert and I get the message, even if the sc_error_exit() should have stopped the insertion. Do I use the macro in a wrong way or is this a bug?

Thanks

Dear @mc73,

After carrying out some tests with the macro within the onBeforeInsert event in the Form application, no problem was found and the macro worked as expected, not inserting the record after activating it.

According to the documentation, it is mandatory to use the sc_error_message() macro before the sc_error_exit() macro. According to your report above, you used the sc_error_message() macro in another event.

Please check again and give us feedback with a result as soon as possible.

Best regards!

Hi Danilo_Lima.

Thank you very much for this information. I placed the sc_error_message() in the same event as the sc_error_exit() and in this case it works perfectly!
I previously tried to handle the message by the sc_alert() but in this case unfortunately no exit is triggered. The same is in the Validation events.
Is there a way to interrupt and exit the process in onBeforeInsert, onBeforeUpdate, onBeforeDelete, onValidation or onValidationFailure without showing an explicit sc_error_message() ?
I have some cases where an alternative sql has to be executed before the insert, update or delete, then an sc_alert() has to be shown, and then the process has to stop, before coming to the standard process.

Thanks and best regards

Hi again,

I just found a workaround for my problem, suppressing the error message triggered with the sc_error_message() by using the sc_error_continue(“insert”) right before. Doing so, the error message is not shown, I can use the sc_alert() for showing an alternative message and after that, the exit is processed.

$params = array(
‘title’ => ‘Title’,
‘type’ => ‘success’,
‘timer’ => ‘3000’,
‘showConfirmButton’ => false,
‘position’ => ‘top-end’,
‘toast’ => true
);
sc_error_continue(“update”);
sc_error_message(“This error message will not be shown”);
sc_alert(“This alternative message will be shown, as the process should not be ended with an error but with an alternative action”, $params);
sc_error_exit();

Thanks again for bringing me in the right direction!

Kind regards