AnsweredAssumed Answered

How to throw and cach Logic Hook errors/exceptions and send error messages to log/GUI?

Question asked by Arpad Szabo on Aug 5, 2016
Latest reply on Aug 8, 2016 by Arpad Szabo

Hello!

 

I just wrote my frist Logic Hook, to clean and stardise the Accounts names (Company names) with a before save hook, like this:

 

<?php
    class Clean
    {
        function CleanName($bean, $event, $arguments)
        {
           $companyname = $bean->name;
           $companyname = ucwords(strtolower(trim(str_replace('"',' ',$companyname))));
           
           $bean->name = $companyname;
        }

 

    }
?>

 

Im curious what happens if there is an error in the variable and the logic hook cant run as expected? In this case i will never know where is the error if I cant get an error message from the logic hook.

 

How to throw error message to the screen , or if it simplier directly to the sugar log like this:

 

206.08.05. 09:17 - Error: "Custom Logic Hook function called CleanName casused error".

 

Asked the support, they said the to the log I can write like this:

$GLOBALS['log']->fatal("yourname: whatever");

 

But I dont know how to implement for this Logic Hook (never done before )

 

 

Im under Sugar 7.7.1. Enterprise.

Thank You for Your Help!

Regards,

Arpad

Outcomes