You are here:
OpportunityContractFlagRollupInterface
Determine when to flag the Opportunity as contract-required. If there is no implementation for this interface, the Opportunity is not flagged.
Type
Loosely typed
Triggered When
The OpportunityContractFlagRollupInterface is called when an Opportunity is inserted or deleted or when a Product track as agreement flag is updated. If an implementation is not available, then no action occurs.
Called In
The OpportunityContractFlagRollupInterface is called in the Opportunity line item trigger handler and the Product2 trigger handler.
Signature
Access |
Signature |
|---|---|
global |
|
Default Implementation
Using the DefaultOpportunityRollupContractFlag
implementation, if at least one Opportunity Product line item is set to Track
as Agreement=true, the Opportunity is set as contract-required.
The DefaultOpportunityRollupContractFlag is not documented because it is a public class.
Other Implementations
None
Input Parameters
methodName
Required
Type: String
The method to execute, for example, rollupContractFlag
IdsToUpdate
Type: List<Id>
The Opportunity line item IDs to update, for example:
List<Id> optyToUpdateIds = (List<Id>) inputMap.get('IdsToUpdate');
Output Parameters
None
Sample Implementation
global with sharing class DefaultOpportunityItemRollupContractFlag implements vlocity_cmt.VlocityOpenInterface
{
public Boolean invokeMethod(string methodName, Map<string, object> inputMap, Map<string, object> outMap, Map<string, object> options)
{
Boolean success = true;
if(methodName == 'rollupContractFlag')
{
rollupContractFlag(inputMap, outMap, options);
}
return success;
}
private static void rollupContractFlag(Map<string, object> inputMap, Map<string, object> outMap, Map<string, object> options)
{
List<Id> optyToUpdateIds = (List<Id>)inputMap.get('IdsToUpdate');
if(optyToUpdateIds != null && optyToUpdateIds.size() > 0)
{
Map<Id, Opportunity> optyMap = new Map<Id, Opportunity>([SELECT
Id,
vlocity_cmt__IsContractRequired__c
FROM
Opportunity
WHERE
Id in: optyToUpdateIds]);
List<OpportunityLineItem> optyItemList = [SELECT
Id,
OpportunityId,
vlocity_cmt__IsProductTrackAgreement__c
FROM
OpportunityLineItem
WHERE
OpportunityId in: optyToUpdateIds
ORDER BY
OpportunityId];
List<Opportunity> optyToUpdate = new List<Opportunity>();
if(optyMap != null && optyItemList != null && optyMap.size() > 0)
{
//update order to have flag to false
for(Id optyId: optyMap.keySet())
{
Opportunity optyObj = optyMap.get(optyId);
optyObj.vlocity_cmt__IsContractRequired__c = false;
optyToUpdate.add(optyObj);
}
if(optyItemList.size() > 0)
{
for(OpportunityLineItem item: optyItemList)
{
if(item.IsProductTrackAgreement__c == true)
{
Opportunity optyObj2 = optyMap.get(item.OpportunityId);
optyObj2.vlocity_cmt__IsContractRequired__c = true;
}
}
}
}
Update optyToUpdate;
}
}
}
