0% found this document useful (0 votes)
1K views

CPQ App Handler Hook Implementation

This document defines a global sharing class that implements a Vlocity interface. The class contains a method that is invoked to modify request parameters before API calls. It appends custom fields to the "fields" and "priceDetailsFields" parameters if they are present, or initializes them if not. This ensures the custom fields are returned in API responses.

Uploaded by

Aarthy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

CPQ App Handler Hook Implementation

This document defines a global sharing class that implements a Vlocity interface. The class contains a method that is invoked to modify request parameters before API calls. It appends custom fields to the "fields" and "priceDetailsFields" parameters if they are present, or initializes them if not. This ensures the custom fields are returned in API responses.

Uploaded by

Aarthy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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