RLI related save issue

Hello,

We were working with RevenueLineItems module logic hook.
And we are facing issue with the save process being very slow.
So to test we created a logic_hook with the following code


Class RLILogicTest{
public function testFunction($bean, $event, $args){
echo "<br>'{$bean->id}' → update FLI record - {$event} - isUpdate:'{$bean->isUpdate()}'";
}
}

On execution it returned 398 lines.
Indicating the logic hook was somehow triggered for all the RevenueLineItems related to the parent Opportunity

We tried to disable all the logic hooks and test, but got same result.

Kindly let us know why, logic hook was triggered for all the RevenueLineItems related to the parent Opportunity.
And how to avoid it, to achieve better performance

Thanks

Parents
  • - you didn't specify which type of logic_hook. I would guess you are using a before_save.

    When an Opportunity is saved. It triggers an update to all of the related Revenue Line Items because there are calculated fields on the RLI. 398 RLI seems to be a large number of RLIs associated with a single Opportunity.

  • Hi Jeff, can we re-engage on this topic. We shifted focus for a bit and are back at it. 

    The related Opportunity and Other FLI related to the Opportunity gets triggered for save process, invoking all the related logic hooks. In our case there are 398 FLIs related to the Opportunity, and altogether they take around 2.7 mins for the execution to complete, in the best case, and 7.9 mins in the worst case.

    To check the cause in detail for such unwanted trigger, we disabled all the custom logic hooks and custom formula fields and checked other implementation  as of know we are not calling any other functions into Logichook related code for Opportunity and FLI, but saw no difference.

    Any other thoughts at what we could look at next? 

Reply
  • Hi Jeff, can we re-engage on this topic. We shifted focus for a bit and are back at it. 

    The related Opportunity and Other FLI related to the Opportunity gets triggered for save process, invoking all the related logic hooks. In our case there are 398 FLIs related to the Opportunity, and altogether they take around 2.7 mins for the execution to complete, in the best case, and 7.9 mins in the worst case.

    To check the cause in detail for such unwanted trigger, we disabled all the custom logic hooks and custom formula fields and checked other implementation  as of know we are not calling any other functions into Logichook related code for Opportunity and FLI, but saw no difference.

    Any other thoughts at what we could look at next? 

Children
  • If you take a look at the cache/modules/Opportunities/Opportunityvardefs.php, near the bottom you will see a field related_calc_fields. This tells Sugar which related modules to update when an Opportunity is saved. In other words, saving an Opportunity will trigger saving all of the related records. Review this and see if it makes a difference.

    related_calc_fields will look similar to 

    'related_calc_fields' => 
    array (
    0 => 'accounts',
    1 => 'leads',
    2 => 'revenuelineitems',
    3 => 'forecastworksheets',
    )