Configuration Loader API
Configuration Load Rule Executor API
Configuration Validator API
Generate Quote Document API
Service Router
CPQ API Quickstart Guide
Disable CPQ Triggers in Apex
Salesforce CPQ Plugins
Previous Versions
The Configuration Loader API returns all the data for the product, including its product options and configuration model. When configuring a nested bundle, set the parentProductproperty to the parent product to inherit configuration attributes on the nested bundle.
| Required Editions |
|---|
| Available in: Salesforce CPQ Spring ’17 and later |
JSON, Apex
PATCH
Authorization: Bearer token
REQUEST
| Name | Type | Description | |
|---|---|---|---|
| uid | String | Required | ID of the Product2 record. |
| quote | QuoteModel | Required | Corresponds directly to SBQQ__Quote__c. |
| parentProduct | ProductModel | Optional | The parent product for a nested bundle. Used to inherit configuration attributes from the parent product. |
RESPONSE
| Type | Description | ||
|---|---|---|---|
| ProductModel | Representation of product data. See CPQ Models. |
1curl "https://*yourInstance*.salesforce.com/services/apexrest/SBQQ/ServiceRouter?loader=SBQQ.ConfigAPI.ConfigLoader&uid=a0x5C000000G1CV" \
2 -H "Content-Type: application/json" \
3 -H "Authorization: Bearer YOURAUTHORIZATIONTOKEN" \
4 -X PATCH \
5 -d "@configLoaderContext.json”The example request body configLoaderContext.json file for loading product data. This example context value is a JSON formatted string of the quote model.
1{"context":"{\"quote\":{\"record\":{\"attributes\":{\"type\":\"SBQQ__Quote__c\",
2 \"url\":\"/services/data/v48.0/sobjects/SBQQ__Quote__c/a0p61000004IpR8AAK\"},
3 \"Name\":\"Q-00905\",
4 \"Id\":\"a0p61000004IpR8AAK\"},
5 \"nextKey\":2,
6 \"netTotal\":0.00,
7 \"lineItems\":[],
8 \"lineItemGroups\":[],
9 \"customerTotal\":0.00},
10 \"products\":[],
11 \"groupKey\":0,
12 \"ignoreCalculate\": true}"}Example response body returning product data. The actual response is a JSON formatted string.
1{
2 "record": {
3 "attributes": {
4 "type": "Product2",
5 "url": "/services/data/v42.0/sobjects/Product2/01tA0000005uzfZ"
6 },
7 "Id": "01tA0000005uzfZ",
8 "Name": "Apple"
9 }
10 "options": [],
11 "features": [],
12 "configuration": {}
13}Before saving the ConfigLoader example class, make sure that the CPQ Modelsclasses are added as individual Apex classes in your org.
1public with sharing class ConfigLoader {
2 public ProductModel load(Id productId, QuoteModel quote, ProductModel parentProduct) {
3 ConfigLoadContext ctx = new ConfigLoadContext(quote, parentProduct);
4 String productJSON = SBQQ.ServiceRouter.load('SBQQ.ConfigAPI.ConfigLoader', productId, JSON.serialize(ctx));
5 return (ProductModel) JSON.deserialize(productJSON, ProductModel.class);
6 }
7
8 private class ConfigLoadContext {
9 private QuoteModel quote;
10 private ProductModel parentProduct;
11
12 private ConfigLoadContext(QuoteModel quote, ProductModel parentProduct) {
13 this.quote = quote;
14 this.parentProduct = parentProduct;
15 }
16 }
17}To demonstrate usage of the ConfigLoader class, run the following code in anonymous Apex.
1QuoteModel quote; //Use Read, Add Products, or Calculate APIs to obtain a QuoteModel
2
3ConfigLoader loader = new ConfigLoader();
4ProductModel product = loader.load('a0x5C000000G1CV', quote, null);
5System.debug(product);