You are here:
OmniCPQServiceWrapper
The OmniCPQServiceWrapper implementation is a class for OmniScript that supports named methods used in guided selling. The createOrder method expects an account ID, order ID, or context ID as input. The context ID is either an account ID or an order ID. The other methods work on the order ID in the input.
Salesforce recommends using the OmniChannel CPQ REST APIs instead of OmniCPQServiceWrapper. For more information, see CPQ APIs To Replace OmniCPQServiceWrapperCPQ APIs to Replace OmniCPQServiceWrapper.
Interface
VlocityOpenInterface2VlocityOpenInterface2
Input Parameters
methodName
Required
Type: String
The method name to execute:
-
addToCart
-
createOrder
-
getAssets
-
getProducts
-
submitOrder
-
updateCart
-
upgradeAsset
Other parameters depend on which method name is executed.
methodName: addToCart
input
Required
Type: Map<String, Object>
All input maps must contain at least one map key per method name. The map key is OrderId, which is the order ID.
output
Required
Type: Map<String,Object>
The output map must contain the vlcCart parameter, a string that is the serialized JSON code that contains the list of items in the cart.
options
Type: Map<String,Object>
Can pass one of the following parameters:
-
vlcSelectedItem
Type: List<Object> or Map<String,Object>
Selected items to add
-
vlcOperation
Type: String
Add, remove, or configure the product
methodName: createOrder
input
Required
Type: Map<String, Object>
All input maps include the following:
-
ContextId
Type: Id
The account or order ID
-
OrderId
Type: Id
The order ID
-
AccountId
Type: Id
The account ID
output
Required
Type: Map<String, Object>
The output map must include the OrderId.
options
Type: Map<String, Object>
Can pass one of the following parameters:
-
Pricebook
Type: String
Name of the price book
-
PricebookId
Type: String
The price book ID
methodName: getAssets
input
Required
Type: Map<String,Object>
All input maps include ContextId, which is the account ID.
output
Required
Type: List<Object>
The output map must include the value of the JSON Node key, a list of assets associated with that account.
options
Type: Map<StringObject>
The options parameter can include the JSON Node, a string that is the name of the target element in the OmniScript.
methodName: getProducts
input
Required
Type: Map<String, Object>
All input maps must contain at least one map key per method name. The map key is OrderId, which is the order ID.
output
Required
Type: Map<String, Object>
The output map must include the following:
-
vlcCart
Type: String
Serialized JSON code that contains the list of items in the cart
-
value of the JSON Node key
Type: List<Object>
List of assets associated with that account
options
Type: Map<String, Object>
Can pass one of the following parameters:
-
JSON Node
Type: String
Name of the target element in an OmniScript
-
Query
Type: String
SOQL query to append in the WHERE clause to filter products
methodName: submitOrder
input
Required
Type: Map<String,Object>
All input maps must contain at least one map key per method name. The map key is OrderId, which is the order ID.
output
Required
Type: Map<String,Object>
The output map must contain the vlcCart parameter, a string that is the serialized JSON code that contains the list of items in the cart.
options
Type: Map<String,Object>
Null
methodName: updateCart
input
Required
Type: Map<String,Object>
All input maps must contain at least one map key per method name. The map key is OrderId, which is the order ID.
output
Required
Type: Map<String,Object>
The output map must contain the vlcCart parameter, a string that is the serialized JSON code that contains the list of items in the cart.
options
Type: Map<String,Object>
Can pass one of the following parameters:
-
vlcSelectedItem
Type: List<Object> or Map<String,Object>
Selected items to add
-
vlcOperation
Type: String
Delete, update, or configure the products in the cart, and then save the products after configuration
methodName: upgradeAsset
input
Required
Type: Map<String,Object>
All input maps include the following:
-
ContextId
Type: Id
The account or asset ID
-
OrderId
Type: Id
The order ID, when using an existing order
output
Required
The output map must include the following:
-
OrderId
Type: Id
The ID of the created order
-
OrderNumber
Type: String
The number of the created order
options
Type: Map<String,Object>
Null
Sample Code
global with sharing class OmniCPQServiceWrapper implements VlocityOpenInterface2
{
global object invokeMethod(string methodName, Map<string, object> inputMap, Map<string, object> outMap, Map<string, object> options)
{
Boolean success = true;
string errors = 'OK';
try
{
if(methodName == 'createOrder')
{
createOrder(inputMap, outMap, options);
}
else if(methodName == 'getProducts')
{
getProducts(inputMap, outMap, options);
}
else if(methodName == 'addToCart')
{
if(options.get('vlcOperation').equals('Add'))
{
addProducts(inputMap, outMap, options);
}
else if(options.get('vlcOperation').equals('Remove'))
{
removeItemFromCart(inputMap, outMap, options);
}
else if(options.get('vlcOperation').equals('configureProd'))
{
configureProduct(inputMap, outMap, options);
}
}
else if(methodName == 'updateCart')
{
if(options.get('vlcOperation').equals('Delete'))
{
deleteItem(inputMap, outMap, options);
}
else if(options.get('vlcOperation').equals('Update'))
{
updateItem(inputMap, outMap, options);
}
else if(options.get('vlcOperation').equals('configureProdInCart'))
{
configureProductInCart(inputMap, outMap, options);
}
else if(options.get('vlcOperation').equals('saveProductsPostConfig'))
{
saveProductsPostConfig(inputMap, outMap, options);
}
else
{
getItems(inputMap, outMap, options);
}
}
else if(methodName == 'submitOrder')
{
submitOrder(inputMap, outMap, options);
}
else if(methodName == 'upgradeAsset')
{
upgradeAsset(inputMap, outMap, options);
}
else if(methodName == 'getAssets')
{
getAssets(inputMap, outMap, options);
}
}
catch(Exception e)
{
Logger.err(e.getStackTraceString());
errors = e.getMessage();
success = false;
}
outMap.put('success', success);
outMap.put('error', errors);
return success;
}
public void getAssets(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void upgradeAsset(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> option)
{
}
public void createOrder(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void getUpdatedCart(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void getProducts(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void addProducts(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void removeItemFromCart(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void deleteItem(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void updateItem(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void submitOrder(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
public void getItems(Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
{
}
}Related Implementations
None

