After_save Logic Hook error

Hi, I have created an after_save Logic Hook for my costum module but when it launch the function it returns me this error:

Fatal error : Uncaught ArgumentCountError: Too few arguments to function GeneraRapportino::generaRapportino(), 0 passed in C:\xampp\htdocs\CRM\include\utils\LogicHook.php on line 270 and exactly 3 expected in C:\xampp\htdocs\CRM\custom\modules\MyCustomModule\GeneraRapportino.php:7 Stack trace: #0 C:\xampp\htdocs\CRM\include\utils\LogicHook.php(270): GeneraRapportino->generaRapportino() #1 C:\xampp\htdocs\CRM\include\utils\LogicHook.php(213): LogicHook->process_hooks(Array, ‘after_save’, ‘’) #2 C:\xampp\htdocs\CRM\data\SugarBean.php(3112): LogicHook->call_custom_logic(‘MyCustomModule’, ‘after_save’, ‘’) #3 C:\xampp\htdocs\CRM\data\SugarBean.php(2427): SugarBean->call_custom_logic(‘after_save’, ‘’) #4 C:\xampp\htdocs\CRM\include\SugarObjects\templates\sale\Sale.php(164): SugarBean->save(false) #5 C:\xampp\htdocs\CRM\include\MVC\Controller\SugarController.php(684): Sale->save(false) #6 C:\xampp\htdocs\CRM\include\MVC\Controller\SugarController.php(525 in C:\xampp\htdocs\CRM\custom\modules\MyCustomModule\GeneraRapportino.php on line 7

To create the Logic Hook I have edited \custom\modules\logic_hook.php like this

And in \custom\modules\MyCustomModule I have created a file named GeneraRapportino.php and the first rows are ( the error is refered to the declaretion of the function that i do following the manual)

What could be the problem?

SuiteCRM is calling the class and functions as it normally do. It’s your custom code that needs to be reviewed.



I have commented all the code of my function (i have only the declaration of the class and of the function) but it still gives me the same error

If i change the function without parameter it works correct, the problem is that i need at least the id of the element that is being saved.

If all you need is the id, you can obtain it with:

$yourVariable = $bean->id;



You also need to change the function name.
It shouldn’t be the same name as the class name since that would make it a constructor.

1 Like

@blqt Technically, the name is different (Please note uppercase on Class)

What I just noticed is that you are using you are calling your logic hook from the General LogicHook file \custom\modules\logic_hook.php If it only affects your custom module, you should create/modify file \custom\modules\YourCustomModule\logic_hook.php and call your custom logichook file from there.

The other thing I noticed and to be honest I don’t know if that creates any issue. But the multiple logichook’s are using sort order 1. Try to use different numbers on all of them to see if that makes any difference.
More info on Sort Order here:



You are right, after i created the Loogic_Hook.php file in \custom\modules\MyCustomModule the code is executed.
I have only one question left: how could I execute a javascript function inside a logic hook? (I try to execute a simple console.log or but they didn’t work, they work only if I put an “exit” in php)

If that solved the issue please mark my answer as the solution and create a new post for your new question. That way the forum remains clean and in order for other people to navigate trough it.



This helped. Thank you.