How do I guarantee that my after_save executes first than after_relationship_add

Hi everybody

Excuse me for my english, so I’ve a problem, I created a after_save and after_relationship_add but the after_relationship_add is running before the after_save and I need the one that runs first to be the after_save, here my logic_hook.php code:

// 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, 'Opportunities push feed', 'modules/Opportunities/SugarFeeds/OppFeed.php','OppFeed', 'pushFeed'); 
$hook_array['before_save'][] = Array(77, 'updateGeocodeInfo', 'modules/Opportunities/OpportunitiesJjwg_MapsLogicHook.php','OpportunitiesJjwg_MapsLogicHook', 'updateGeocodeInfo');
$hook_array['before_save'][] = Array(78, 'before_save', 'custom/modules/Opportunities/Opportunities_before_save.php','Opportunities_before_save_class', 'Opportunities_before_save_method'); 
$hook_array['after_save'] = Array(); 
$hook_array['after_save'][] = Array(77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Opportunities/OpportunitiesJjwg_MapsLogicHook.php','OpportunitiesJjwg_MapsLogicHook', 'updateRelatedMeetingsGeocodeInfo'); 
$hook_array['after_save'][] = Array(78, 'updateRelatedProjectGeocodeInfo', 'modules/Opportunities/OpportunitiesJjwg_MapsLogicHook.php','OpportunitiesJjwg_MapsLogicHook', 'updateRelatedProjectGeocodeInfo');
$hook_array['after_save'][] = Array(79, 'after_save', 'custom/modules/Opportunities/Opportunities_after_save.php','Opportunities_after_save_class', 'Opportunities_after_save_method');
$hook_array['before_delete'] = Array();
$hook_array['before_delete'][] = Array(77, 'before_delete', 'custom/modules/Opportunities/Opportunities_before_delete.php','Opportunities_before_delete_class', 'Opportunities_before_delete_method');
$hook_array['after_relationship_add'] = Array(); 
$hook_array['after_relationship_add'][] = Array(77, 'addRelationship', 'modules/Opportunities/OpportunitiesJjwg_MapsLogicHook.php','OpportunitiesJjwg_MapsLogicHook', 'addRelationship'); 
$hook_array['after_relationship_add'][] = Array(80,'after_relationship_add','custom/modules/Opportunities/Opportunities_after_relationship_add.php','Opportunities_after_relationship_add_class','Opportunities_after_relationship_add_method');
$hook_array['after_relationship_delete'] = Array(); 
$hook_array['after_relationship_delete'][] = Array(77, 'deleteRelationship', 'modules/Opportunities/OpportunitiesJjwg_MapsLogicHook.php','OpportunitiesJjwg_MapsLogicHook', 'deleteRelationship');

Could someone tell me why this happens?


What are you trying to Achieve ? What is the logic that you need to be set in After save ?

Hi cherub-chum

I use QuickCRM as an alternative to have the functionality of SuiteCRM on my cell phone, as QuickCRM uses the API Rest of SuiteCRM the operations that have related modules do not work in the after_save but they work in the after_relationship_add, but when including that logic hook as part From my development, after_save stops working in SuiteCRM but it works properly in QuickCRM, what I require is knowing how to make it run in the correct order in SuiteCRM which is after_save and then after_relationship_add

You can add a flag in the First Hook (set a bean variable) and the test that in the second one?

I am trying set a bean variable in the after_relationship_add and getting in the after_save but my screen appears white without message, my code as follow:

class Opportunities_after_relationship_add_class
function Opportunities_after_relationship_add_method(&$bean, $event, $arguments)
if ($arguments[‘related_module’] ==‘Contacts’)
$GLOBALS[‘log’]->fatal(“Related Module Contacts”);
$opportunityBean = BeanFactory::getBean(‘Opportunities’, $bean->id);
$opportunityBean->envio_sms_analisis_c = 2;


class Opportunities_after_save_class
     function Opportunities_after_save_method(&$bean, $event, $arguments)
          $opportunityBean = BeanFactory::getBean('Opportunities', $bean->id);
          $envio_sms_analisis_c = $opportunityBean->envio_sms_analisis_c;
          $GLOBALS['log']->fatal("Getting value of analysis: $envio_sms_analisis_c");

In your after save code, why are you redeclaring the Bean?

      $opportunityBean = BeanFactory::getBean('Opportunities', $bean->id);

Its already passed to the function as $bean

      $envio_sms_analisis_c = $bean->envio_sms_analisis_c;

Hi cherub-chum

that’s not the problem, I cleaned all the code and when I try to save an opportunity the screen goes blank, I was reviewing the file logic_hook.php and the problem is associated with the call of the after_save and the after_relationship_add.

What do you see in your CRM logs and PHP error logs?

Hi cherub-chum

My PHP error log say the file /custom/modules/Opportunities/M_SMSApiConsume.php doesn’t exists, but it’s very strange because this file exists in that path, for the moment, to make sure that the process is executed by SuiteCRM or QuickCRM I am going to do the following:

if (isset($_POST[‘rest_data’])){

// called by REST API



// called by SuiteCRM