You are on page 1of 2

global with sharing class CpqAppHandlerHookImplementation implements

vlocity_cmt.VlocityOpenInterface
{
global Boolean invokeMethod(String methodName, Map<String, Object> input,
Map<String, Object> output, Map<String, Object> options)
{
try
{
System.debug('____ CpqAppHandlerHookImplementation ' + methodName);

if (methodName == 'postCartsItems.PreInvoke' || methodName ==


'putCartsItems.PreInvoke' ||
methodName == 'deleteCartsItems.PreInvoke' || methodName ==
'getCartsItems.PreInvoke')
{
String customFields = 'Billing_Zip_Code__c'; // comma separated
list of custom fields
// if fields is passed in, append the custom fields to the
parameter value
if (String.isNotBlank((String)input.get('fields')))
{
input.put('fields', input.get('fields') + ',' + customFields);
}
else
{
// if the fields is not passed in, initialize to default price
detail fields and include the custom fields
input.put('fields',
'vlocity_cmt__BillingAccountId__c,vlocity_cmt__ServiceAccountId__c,Quantity,vlocity
_cmt__RecurringTotal__c,' +

'vlocity_cmt__OneTimeTotal__c,vlocity_cmt__OneTimeManualDiscount__c,vlocity_cmt__Re
curringManualDiscount__c,' +

'vlocity_cmt__ProvisioningStatus__c,vlocity_cmt__RecurringCharge__c,vlocity_cmt__On
eTimeCharge__c,ListPrice,' +

'vlocity_cmt__ParentItemId__c,vlocity_cmt__BillingAccountId__r.Name,vlocity_cmt__Se
rviceAccountId__r.Name,' +

'vlocity_cmt__PremisesId__r.Name,vlocity_cmt__InCartQuantityMap__c,vlocity_cmt__Eff
ectiveQuantity__c' + ',' + customFields);
}
// if priceDetailsFields is passed in, append the custom fields to
the parameter value
if (String.isNotBlank((String)input.get('priceDetailsFields')))
{
input.put('priceDetailsFields', input.get('priceDetailsFields')
+ ',' + customFields);
}
else
{
// if the priceDetailFields is not passed in, initialize to
default price detail fields and include the custom fields
input.put('priceDetailsFields',
'vlocity_cmt__RecurringCharge__c,vlocity_cmt__RecurringTotal__c,vlocity_cmt__OneTim
eCharge__c,' +
'vlocity_cmt__OneTimeTotal__c' + ',' + customFields);
}
}
return true;
}
catch (Exception ex)
{
System.debug('--- Exception: ' + ex.getMessage());
System.debug('--- Stack Trace: ' + ex.getStackTraceString());
throw ex;
}
}
}

['Capex__c']['value']
['Opex__c']['value']
['Cost__c']['value']

['Capex__c']['label']
['Opex__c']['label']
['Cost__c']['label']

['One_Time_Cost_Total__c']['label']
['One_Time_Cost_Total__c']['value']

['vlocity_cmt__RecurringMargin__c']['value']
['vlocity_cmt__RecurringMargin__c']['label']

['vlocity_cmt__OneTimeMargin__c']['value']
['vlocity_cmt__OneTimeMargin__c']['label']

You might also like