Use case: Using the Salesforce Quote Calculator plugin to integrate data from ServiceNow CPQ to Salesforce quotes and quote lines
Summarize
Summary of Using the Salesforce Quote Calculator plugin to integrate data from ServiceNow CPQ to Salesforce quotes and quote lines
This use case explains how to integrate and transfer extended configuration data from ServiceNow CPQ into Salesforce CPQ quotes and quote lines using the Salesforce Quote Calculator Plugin (QCP). It applies specifically to the ServiceNow CPQ Extension for Salesforce CPQ package version 1.7 or earlier. The integration leverages the ProductList.extended JSON object to pass custom data from ServiceNow CPQ into Salesforce quote line fields.
Show less
Key Features
- ProductList.extended JSON object: Holds key:value pairs or arrays of JSON objects with extended product information, populated via advanced product actions in ServiceNow CPQ.
- Bill of Materials (BOM) Data: The extended information is stored in a custom object “BOM Data” at the quote line level for configurable products.
- Quote Calculator Plugin (QCP) Script: Custom scripts in Salesforce parse the BOM Data JSON to extract relevant extended info and map it to Salesforce quote or quote line fields.
- Example Script: Demonstrates how to locate specific products in BOM data, parse their extended fields, and set corresponding quote line fields, enabling dynamic updates during quote calculations.
- Configuration Requirements: All quote and quote line fields accessed by the script must be explicitly defined as inputs in the custom script record in Salesforce CPQ.
- Deployment Steps: The custom script is uploaded and configured in Salesforce CPQ under Installed Packages > Salesforce CPQ > Pricing and Calculation > Plugins, enabling the QCP to execute on quote recalculations.
Key Outcomes
- Enables seamless passing of detailed configuration data from ServiceNow CPQ into Salesforce CPQ quote and quote line records.
- Allows customers to customize and manipulate Salesforce quote fields dynamically based on complex product configurations managed in ServiceNow CPQ.
- Improves accuracy and efficiency in quote management by synchronizing extended configuration attributes automatically during quote calculations.
- Provides a clear framework for integrating advanced CPQ data flows using the Salesforce Quote Calculator Plugin and custom scripting.
In the ServiceNow CPQ Extension for Salesforce CPQ package version 1.7 or earlier, use the Salesforce Quote Calculator Plugin to parse extended information from a configuration and map it to custom fields.
Using the extended information of the ServiceNow CPQ ProductList object with the Salesforce Quote Calculator plugin (QCP), data may be passed from ServiceNow CPQ into Salesforce and used to manipulate both quote and quote line information.
ProductList.extended may only be populated with an advanced product action, as shown here.
The ProductList.extended object takes the form of a JSON object and accepts key:value pairs. In the example above, we pass through a dummy text string, “QCP Test Value”, with the newValue key. ProductList.extended can hold field values, as well as an array of JSON objects.
When this product is added to the bill of materials (BOM), we can view its associated info in the custom object “BOM Data”, which is held at the quote line of the configurable product.
To leverage this extended information, we will need to use the Quote Calculator Plugin. To start, navigate to the Custom Scripts item in Salesforce.
Here, you can write a script to leverage the extended information from ServiceNow CPQ and use it to manipulate fields in SFDC. The following script is the sample script used in this instance.
export function onBeforeCalculate(quote, lines) {
var result;
var resultValue;
var product_code = "headlessItem3";
if (lines != null) {
lines.forEach(function (line) { //Parsing all quote lines to find BOM Data object
if(line.record["LGK__BomData__c"] != null){
var configJson = JSON.parse(line.record["LGK__BomData__c"]);
var itemsJson = configJson["items"]; //Create JSON object containing all items in BOM data
itemsJson.forEach(function(itemsLine){ //For each item in the BOM Data
if(itemsLine["productCode"] == product_code){ //Checking for item "headlessItem3"
result = itemsLine["extended"]; //Parses extended information to find "newValue"
resultValue = result["newValue"]; //Assigning keyed value of "newValue"
}
});
}
});
lines.forEach(function (line) { //For each line in the quote
if (line.record["SBQQ__ProductCode__c"] == product_code){ //Checking for the line item "headlessItem3"
line.record["Test_Text__c"] = resultValue; //Setting the quote line field "Test Text" with the value of resultValue
}
});
}
return Promise.resolve();
};
Any quote fields or quote line fields referenced by the custom script must be explicitly defined in the appropriate inputs on the custom script record. Our sample script references three quote line fields: LGK_BomData c, SBQQ_ProductCode c, and Test_Text c.
Once your script has been written, define it in the Salesforce CPQ settings. Follow these steps:
- In Setup, search for “Installed Packages” using Quick FInd.
- Next to “Salesforce CPQ”, click Configure.
- Select the Pricing and Calculation tab.
- If necessary, deselect Use Calculator.
- Select the Plugins tab.
- Define your custom script in the Quote Calculator plugin, and then click
Save.
When you navigate to your quote and trigger any action that performs a calculation in SFDC (such as clicking “Calculate”), the Quote Calculator Plugin runs and modifies fields as designated.