When using before_save in SugarCRM 6.5 how do I stop the save?

I am going to use before_save to review a Merge before it completes. 

If both Contact records have the two different Student Ids, I want to stop the process and display a message saying it can't be done.

Parents
  • Try paste this when you need show error:

    require_once 'include/api/SugarApiException.php';
    throw new SugarApiExceptionInvalidParameter("It can't be done");
    
Reply
  • Try paste this when you need show error:

    require_once 'include/api/SugarApiException.php';
    throw new SugarApiExceptionInvalidParameter("It can't be done");
    
Children
  • I don't believe that works with 6.5. Plus I don't have the file include/api/SugarApiException.php in the SugarCRM 6.5 instance.

  • A brute way of doing it is:

    die("it can't be done.");

    Or you can:

    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;">it can't be done.</span></div>'

                    );