Ok, so I know i’ve seen a comment about this issue somewhere :dry: just can’t remember where lol.
So you have some custom logic hooks that you have created and your all so happy but then you realize that you forgot to include a crucial part in the module builder, but wait if you use the module builder and set it up and re-deploy you will loose all those logic_hooks that you spent so much time setting up.
Yes, I cursed my computer out a couple of times on this one. Then I thought you know what lets see what happens if I create the files that I need and then set the files to read only. So I did that and then re-deployed the module after making the changes. Since I redeployed I would have to also do a repair and rebuild in order for the logic_hooks to be used. So I did the repair and rebuild and all was right in universe again :).
I put the following file in the following directory and made it read only
custom/modules/Accounts/ConcatNameFieldsLogicHook.php
<?php
class ConcatNameFieldsLogicHook{
public function concatnamefields(SugarBean $bean, $event, $arguments){
$bean->name = $bean->name_first . " " . $bean->name_last;
}
}
then i put the following file in it’s directory and made it read only
/custom/Extension/modules/[module]/Ext/LogicHooks/Custom_Accounts_Logic_Hooks.php
<?php
$hook_array['before_save'][] = Array(1, 'Concatenate First and Last Name to Name Field', 'custom/modules/Accounts/ConcatNameFieldsLogicHook.php','ConcatNameFieldsLogicHook', 'concatnamefields');
So, I included the code and as you can see it doesn’t do anything too spectacular except take the first and last name field concantenate them and place it in the name field in the database even though the ‘name’ field is no where on my layout
it works just find and it saved me some time so I though i’d share it in case someone else ran into the same issue.
Cheers