AnsweredAssumed Answered

Logic Hooks not executing

Question asked by Colin Schouten on Mar 16, 2017
Latest reply on Mar 23, 2017 by Michael Joyner

Hi Sugar Developer Community,

 

In our Opportunities module, we have a before_save and several after_save logic hooks associated to multiple customizations. Please see the code below:

<?php
$hook_array['before_save'][] = Array(
    2,
    'Retrieve and compare values',
    'custom/modules/Opportunities/createSalesStageRecord.php',
    'createSalesStageRecord',
    'previousStage'
);
$hook_array['after_save'][] = Array(
    2,
    'Create SSH Record',
    'custom/modules/Opportunities/createSalesStageRecord.php',
    'createSalesStageRecord',
    'currentStage'
);
$hook_array['after_save'][] = Array(
    4,
    'If new Primary Event value in Opportunity record, add new Event record if it does not already exist',
    'custom/modules/Opportunities/oppPrimaryEvent.php',
    'oppPrimaryEvent',
    'addOppPrimaryEvent'
);
$hook_array['after_save'][] = Array(
    5,
    'If Opportunity is updated, update all associated Event records',
    'custom/modules/Opportunities/updateAssociatedEvents.php',
    'updateAssociatedEvents',
    'updateEventRecords'
);

 

The problematic module is Sales Stage History, which compares the previous sales stage value to the new sales stage value, calculates how long it was in the old sales stage, and then posts this information in a record into the Sales Stage History module. So, the logic hooks associated to the createSalesStageRecord actions are giving us the trouble here. In our instance, when a new Opportunity is created, I know the after_save logic hooks execute just fine because the Sales Stage History record is created.

 

Now, if a user goes into said Opportunity, and updates the Sales Stage History to another value, the before_save and after_save logic hook fail and no record is created.

 

At one point in time, the Sales Stage History logic hooks were the only logic hooks in the Opportunities module, and it worked perfectly. But now that we've added some more logic hooks to Opportunities, I can't help but think it's a logic hook processing issue. There really isn't any formal documentation on logic hook processing order and multiple customizations for one module. I've be racking my brain for some time around this issue, and I can't seem to determine a solution. 

 

Could someone please assist? Thanks!

Outcomes