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? 

  • 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',
    )
  • Hi Jeff, 

    Please find the below is what we are using the opportunities relate fields:

    ),
    'importable' => true,
    'custom_fields' => true,
    'has_pii_fields' => false,
    'related_calc_fields' =>
    array (
      0 => 'opportunities',
     ),
    ;

    Logichooks in Forecast Line Items :

    When we edit the records in FLI  other logichooks are getting triggered:

    We have written only one logic hook in the FLI. In this logic hook we are have added following relationship ID :

    Relationship Name

    Relationship ID

    account_link

    account_id

    teams

    team

    rli_templates_link

    rli_templates_id

    opportunities

    opportunity_id

    assigned_user_link

    assigned_user_id

    fbsg_physicians_revenuelineitems_1

    fbsg_physicians_revenuelineitems_1fbsg_physicians_ida

    But the FLI is triggering multiple logichooks without adding any relationship ID in the FLI  logic hook from Order Tracking and Inventory Transaction Profiles.

    In Order Tracking Profile, it’s triggering the following logichooks : 

    File Path

    Functionality

    custom/include/logichooks/ORD_Orders_Tracking/UpdateCalculatedfields.php

    In this file, we have written a logic hook to update the calculated fields through code and removed those calculated fields in the UI to increase the performance.

    custom/include/logichooks/ORD_Orders_Tracking/Accounts_sales_ydt.php

    In this file, we have written a logic hook to update YTD Sales in accounts whenever Order Status values are updated.

    custom/include/logichooks/ORD_Orders_Tracking/CreateTrunkStockInventory.php

    In this file, we have written a logic hook to create the record in Trunk Stock Inventory When status = "Send To Billing".

     

    In Inventory Transaction Profile, it’s triggering the following logichooks :

     

    File Path

    Functionality

    custom/include/logichooks/Ve_InventoryTransactions/UpdateApprovedDate.php

    In this file, we have written a logic hook to update the Approved Date same as the date modified when the status is set to Approved.

    custom/include/logichooks/Ve_InventoryTransactions/LinkDocumentInIT.php

    In this file, we have written a logic hook to attach the documents for inventory transactions.

    If there is no relationship why are these loginhooks triggering? 

    Thank you, brooke

Reply
  • Hi Jeff, 

    Please find the below is what we are using the opportunities relate fields:

    ),
    'importable' => true,
    'custom_fields' => true,
    'has_pii_fields' => false,
    'related_calc_fields' =>
    array (
      0 => 'opportunities',
     ),
    ;

    Logichooks in Forecast Line Items :

    When we edit the records in FLI  other logichooks are getting triggered:

    We have written only one logic hook in the FLI. In this logic hook we are have added following relationship ID :

    Relationship Name

    Relationship ID

    account_link

    account_id

    teams

    team

    rli_templates_link

    rli_templates_id

    opportunities

    opportunity_id

    assigned_user_link

    assigned_user_id

    fbsg_physicians_revenuelineitems_1

    fbsg_physicians_revenuelineitems_1fbsg_physicians_ida

    But the FLI is triggering multiple logichooks without adding any relationship ID in the FLI  logic hook from Order Tracking and Inventory Transaction Profiles.

    In Order Tracking Profile, it’s triggering the following logichooks : 

    File Path

    Functionality

    custom/include/logichooks/ORD_Orders_Tracking/UpdateCalculatedfields.php

    In this file, we have written a logic hook to update the calculated fields through code and removed those calculated fields in the UI to increase the performance.

    custom/include/logichooks/ORD_Orders_Tracking/Accounts_sales_ydt.php

    In this file, we have written a logic hook to update YTD Sales in accounts whenever Order Status values are updated.

    custom/include/logichooks/ORD_Orders_Tracking/CreateTrunkStockInventory.php

    In this file, we have written a logic hook to create the record in Trunk Stock Inventory When status = "Send To Billing".

     

    In Inventory Transaction Profile, it’s triggering the following logichooks :

     

    File Path

    Functionality

    custom/include/logichooks/Ve_InventoryTransactions/UpdateApprovedDate.php

    In this file, we have written a logic hook to update the Approved Date same as the date modified when the status is set to Approved.

    custom/include/logichooks/Ve_InventoryTransactions/LinkDocumentInIT.php

    In this file, we have written a logic hook to attach the documents for inventory transactions.

    If there is no relationship why are these loginhooks triggering? 

    Thank you, brooke

Children
No Data