Custom Flow for Pricing Variable Calculation

You can implement custom flow for pricing variable calculation with Standard Cart APIs. The process involves 2 steps:

  1. Setting Up the Interface
  2. Using the Existing Data
  1. Create a custom apex class as follows: Custome Apex Class Ensure to add the namespace of the org before class and method names in the managed orgs.

  2. Create an interface as follows: Create an Interface

  3. Run EPC Compile job.

The data passed in the input and output map of the calculate method is as follows:

  • String objectType: This field stores the type of object passed like orderItem. It can be fetched using get operator.
  • Boolean isRoot: This value represents if the item being calculated is the bundle's root. It can be fetched using get operator.
  • Double effectiveQuantity: This field stores the quantity of the item passed. It can be fetched using get operator.
  • Map<String, Object> pricingVariableCodeValueMap: This map stores values of relevant pricing variables mapped to its code. It can be fetched using get operator.

Input Map

  • Map<String, Integer> pricingVariableCodeToRoundingScale: This has the map for rounding scale to pricing variable code. It can be fetched using get operator.
  • Map<String, String> pricingVariableCodeToFieldBindingLabels: This has the map for field binding labels to pricing variable code. It can be fetched using get operator.
  • String isCostAndMarginFeatureEnabled: This value represents if Cost and Margin feature is enabled. It can be fetched using get operator.
  • String marginCalculationType: This field stores margin calculation type which is information relevant to cost and margin feature. It can be fetched using get operator.
  • CartDocument cartDocument: This is a custom-type map that stores extensive information about the current cart. This cannot be extracted directly using get operator. Please use methods specifically designed for CartDocument to get relevant information. For more information, see Use Cart Documents.
  • String itemId: This stores the itemId for the current lineitem that is being processed. Depending on the org GUID (UseAssetReferenceIdForParentAndRoot CPQ Config) value, it can be salesforceId or assetreferenceId. It can be fetched using get operator.

NOTE:

Please do not try using debug statements that serialize the input map.

System.debug('debug post input: '+json.serialize(input));

Input map contains an object for CartDocument, which is a custom Java type and cannot be serialized directly by the apex layer. Please use methods specifically designed for CartDocument to get relevant information.

  • Map<String, Object> calculatedPricingLogData: This stores the pricing information for pricing variables of the processed item. It can be fetched using get operator.

Output Map

  • Based on the itemId (salesforceId or GUID) in the input map, additional queries can be written to find out more details about the item including relational fields.

Fields

  • Query to get the GUID status of the org:
  • To get the XLI custom field values without doing an additional SOQL call, we can use the ‘fields’ param in the getCartItems API. This would populate this custom field response in cartDocument in case it is a non-null value.