You are here:
OrderContractFlagRollupInterface
Determine when to flag an Order as contract-required. If there is no implementation for this interface, the Order is not flagged.
Type
Loosely typed
Triggered When
The OrderContractFlagRollupInterface is triggered when an Order item 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 OrderContractFlagRollupInterface is called in the Order item trigger and the Product2 trigger.
Signature
Access |
Signature |
|---|---|
global |
|
Default Implementation
Using the DefaultOrderItemRollupContractFlag
implementation, if at least one Order Product line item is set to Track as
Agreement=true, set the Order as contract-required.
The DefaultOrderItemRollupContractFlag implementation is not documented because it is a public class.
Other Implementations
None
Input Parameters
methodName
Required
Type: String
The method to execute, rollupContractFlag
IdsToUpdate
Type: List<Id>
The Order line item IDs to update, for example:
List<Id> orderToUpdateIds = (List<Id>) inputMap.get('IdsToUpdate');
Output Parameters
None
Sample Implementation
global with sharing class CustomOrderItemRollupContractFlag 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> orderToUpdateIds = (List<Id>)inputMap.get('IdsToUpdate');
if(orderToUpdateIds != null && orderToUpdateIds.size() > 0)
{
Map<Id, order> orderMap = new Map<Id, order>([SELECT
Id,
vlocity_cmt__IsContractRequired__c
FROM
Order
WHERE
Id in: orderToUpdateIds]);
List<OrderItem> orderItemList = [SELECT
Id,
OrderId,
vlocity_cmt__IsProductTrackAgreement__c
FROM
OrderItem
WHERE
OrderId in: orderToUpdateIds
ORDER BY
OrderId];
List<order> orderToUpdate = new List<order>();
if(orderMap != null && orderItemList != null && orderMap.size() > 0)
{
//update order to have flag to false
for(Id orderId: orderMap.keySet())
{
Order;
orderObj = orderMap.get(orderId);
orderObj.vlocity_cmt__IsContractRequired__c = false;
orderToUpdate.add(orderObj);
}
if(orderItemList.size() > 0)
{
for(OrderItem item: orderItemList)
{
if(item.IsProductTrackAgreement__c == true)
{
Order;
orderObj2 = orderMap.get(item.OrderId);
orderObj2.IsContractRequired__c = true;
}
}
}
}
Update orderToUpdate;
}
}
}

