I cant find Logic_hooks.php in bugs module


I need to create a logic hooks in order to update a date field with fixed time.
my SuiteCRM version 7.11.10

I have teh folloing code

        ini_set('display_errors', 1); 
	if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
	class UpdateDatesClass { 
             function UpdateDatesFunction($bean, $event, $arguments) 
                         $date = new DateTime($bean->date_asigned_c); 
                         $data_temp_var = $date->format('Y-m-d H:i:s'); 
                         $timedate = new TimeDate();
                         $bean->date_next_assign_c = $timedate->fromString($date_temp_var, $current_user)->asDb(); 

but when i tried to update the logic_hook.php in the custom/module/bug the php file does not appear.

how I can recovery this file? i reapired teh isntallation but the file does not appear.

Hi, welcome to the Community! :tada:

It is normal for files NOT to exist in custom, until you create them.

See here for an introductory tutorial: https://pgorod.github.io/Custom-folder/

And of course there are the Docs on Logic Hooks which explain where to put your new file, and what to write in it:


Thanks for your quick answer, but all Logic_hooks have lines with paths with php files, feeding the array.

$hook_array['before_save'] = Array(); 
$hook_array['before_save'][] = Array(1, 'Cases push feed', 'modules/Cases/SugarFeeds/CaseFeed.php','CaseFeed', 'pushFeed'); 
$hook_array['before_save'][] = Array(10, 'Save case updates', 'modules/AOP_Case_Updates/CaseUpdatesHook.php','CaseUpdatesHook', 'saveUpdate'); 
$hook_array['before_save'][] = Array(11, 'Save case events', 'modules/AOP_Case_Events/CaseEventsHook.php','CaseEventsHook', 'saveUpdate'); 

as you ca see the paths are “module oriented”. I mean that has specifict path to the PHP files I don’t know how create from scratch the logic_hook for module Bug, i was looking for teh file in modules but I didnt find.

Is there any template?

Those hooks are for files that reside in the core directories. Normally you would create yours under custom/modules/Bugs for example, but it’s really arbitrary. You can put it anywhere as long as you use the correct path in the file that adds the hook to the $hook_array.

This section of the document I linked above explains the “template”


You really don’t need to know much more than that. Hooks can be very short and they do their own thing, you’re not really editing any existing code, just adding your own.

I am not sure if I follow you but I was looking the logic_hook.php for Bugs module and I didnt fine. so I created a file similar to cases using the $hook_array as follow:

// Do not store anything in this file that is not part of the array or the hook version.  This file will	
// be automatically rebuilt in the future. 
 $hook_version = 1; 
$hook_array = Array(); 
// position, file, function 
$hook_array['before_save'] = Array(); 
$hook_array['before_save'][] = Array(1, 'Bug Example name', 'modules/Bugs/bsHooks/UpdateName.php','BugsNameClass', 'BugsNameFunction'); 


then I created a UpdateName.php in the path specified with the correct class and funtion.
I repaired the instalation and ran the update in bugs module but the logic_hook does not work neither error message appear.


 ini_set('display_errors', 1); 
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
class BugsNameClass { 
	function BugsNameFunction($bean, $event, $arguments) 
	$$bean->name = strtoupper($bean->name);

below is the custom directory wher the php where copies.


is something else that i need to do to activate logic_hooks in the BUG module?

Cases Module is working well.

I recommend placing your file under


It’s better to keep everything related to customizations under custom.

But it should be working the way you did it. It’s likely that the hook is running.

However, in your code you have a double $$ where you should have only one $.

Also, changing the bean variable like that won’t have any noticeable effect. You need to save the Bean. BUT watch out, this might create an infinite loop. See this post for a solution with sample code:


I placed the php in custom/modules/bugs/dbHooks, as well fixed the $$ error . However the logic_hook for Bugs does not run.
I believe that because I created the locig_hooks.php from scrach there is additional changes that I need todo to allow that it run before_save.
I was lookng Cases, Account and other that have already logic_hook.php created in custom module path and there are additional arrays with php referenced to the modules/,

I don’t knwo I was clear thet the locig_hook.php in the BUGs module did not exist after the installation.

Check this sample:

@AlxGr thanks for yout input, I used last week this example to test logic_hook, and it worked in my enviroment well. My need is to do the same example in the BUGs module, where logic-hook does not exist after the installation. I don’t know how create and activate the logic_hook from scrach. I saw that Accounts, cases, Contact have already logic_hook.php in custom/modules//logic_hooks.php. As you can see before I create all structure but the locig_hook does not worked neither error.log has any entry.

@ariajf00 believe me, the logic hook not existing beforehand is not an issue. It’s perfectly normal.

I am still not convinced you have ruled out the possibility that you’re logic hook is running, only you’re not seeing any effect of it. You should start the hook by logging a FATAL error message saying “I was here” so you can be sure it’s triggering, and only then focus on solving any other code issues.

Apology you are right, I had a mistake with the path of the logical_hook, even thougth the php program was located in custom/module/bug/bsHook the path in the logical_hook.php was modules/bug/
So sorry to waste your time. the issue was solved.

1 Like

:cool: I am just glad you got it working!