I am customizing a before_save hook in contacts but I would like to introduce a condition (that requires to run a DB check) that if matches would stop the "save" of the record of the new Contact I am trying to introduce in the system.
I mean, I go to contacts, create a new record, introduce the data and click on save.... the SugarCRM system goes to the before_save logic hook I have created and runs the condition check, if the data introduced matches the condition, I want the system to
a) Show an error message and remain in the Edit View data with the data introduced.
b) Stop the "save" of the record.
As far as I got is to introduce this code in the logic_hook
SugarApplication::appendErrorMessage('<div style="color:#555; border-radius:10px; font-family:Tahoma,Geneva,Arial,sans-serif;font-size:11px; padding:10px 10px 10px 36px; margin:10px; border:1px solid #f5aca6; background:#ffecec 50%;">
<span style="font-weight:bold; text-transform:uppercase;">No existe tanto producto en el almacén.</span></div>');
The problem is that this funcion shows the errror message I need, but the record gets saved anyway, and the view gets redirected to the Detail View of the record save.
Is there anyway to get the behaviour I need in SugarCRM CE v6.5???
Thanks a lot so much.