The out-of-the-box RelatedLineItem trigger, in it’s update block, allocates the net price of the service line item to all associated related line item records based on the Weightage Type and Weightage Amount fields. However, some customers may have their own allocation model and want to customize it based on their requirements. For such customers, the out-of-the-box RelatedLineItem trigger is redundant and can impact performance. CPQ allows you to control the execution of the RelatedLineItem trigger. You can use the global flag isTriggerInitiatedUpdate to conditionally skip the trigger logic, which allocates the net price of the service line item, and to avoid the unnecessary code execution and potentially improve performance in such cases.

The isTriggerInitiatedUpdate flag controls the “before and after update” block only. However, CPQ executes the “before and after insert” block regardless of the value of this flag. This flag remains set for the whole transaction until you unset the flag or until the transaction ends. Currently, CPQ respects this flag only in the RelatedLineItem trigger.

To configure the global flag

PurposeValue of the FlagDescription
To set the global flagApttus_Config2.RuntimeContext.getParameters().put('isTriggerInitiatedUpdate','true');When the value of the flag is set to True, CPQ skips the execution of the RelatedLineItem trigger. CPQ does not use the out-of-the-box logic to allocate the net price of the service line item to all related line items on updating the related line items from the custom code.
To unset the global flagApttus_Config2.RuntimeContext.getParameters().put('isTriggerInitiatedUpdate', 'false');When the value of the flag is set to False, CPQ executes of the RelatedLineItem trigger. CPQ uses the out-of-the-box logic to allocate the net price of the service line item to all related line items based on the Weightage Type and Weightage Amount on updating the related line items from the custom code.


The following is an example of custom code for reference:

List<Apttus_Config2__RelatedLineItem__c> RLIs = [SELECT Id, Apttus_Config2__WeightageType__c, Apttus_Config2__WeightageAmount__c FROM Apttus_Config2__RelatedLineItem__c WHERE Apttus_Config2__LineItemId__c = 'a132i0000012WS9'];
RLIs.get(0).Apttus_Config2__WeightageType__c = 'Percentage';
RLIs.get(1).Apttus_Config2__WeightageType__c = 'Percentage';
RLIs.get(2).Apttus_Config2__WeightageType__c = 'Percentage';
RLIs.get(0).Apttus_Config2__WeightageAmount__c = 30;
RLIs.get(1).Apttus_Config2__WeightageAmount__c = 30;
RLIs.get(2).Apttus_Config2__WeightageAmount__c = 40;

Apttus_Config2.RuntimeContext.getParameters().put('isTriggerInitiatedUpdate','true');
Database.update(RLIs);
CODE

Here the isTriggerInitiatedUpdate flag is set to True.