Create an external connection
Create an external connection in CPQ to enable enrichments to retrieve data from an external system for use in configuration rules.
Before you begin
Role required: admin
About this task
External connections are used in configuration rules only. They can only be called from an enrichment script. After you configure an external connection, reference it in your enrichment script using
External.connectionName(inputs), where connectionName is the unique name of the connection.
Procedure
Result
The external connection is saved and available to call from enrichment scripts.
BOM enrichment using an external pricing connection
The following on-BOM-response enrichment calls a powerPricing external connection to retrieve customer-specific rate data and apply it to ProductList records. The connection accepts two input
variables — membershipCode and icp — and returns a pricing response that the script uses to set prices on individual products.
var powerInputs = {"membershipCode": cfg.eCMembershipCode, "icp": cfg.eCICPNumber};
let powerResponse = External.powerPricing(powerInputs);
let dailyCharge = 0;
let ratesArr = [];
if (powerResponse.status == 200) {
for (var record of powerResponse.body) {
if (record.chargeType == cfg.expectedUsage) {
dailyCharge = record.dailyCharges;
ratesArr = record.rates;
}
}
for (var prod of ProductList) {
if (prod.id == "electricBillEstimator") {
let addedPrice = dailyCharge * cfg.serviceDurationInDays;
prod.price = addedPrice;
}
if (prod.id == "Standard Rate" || prod.id == "Low Rate") {
prod.price = dailyCharge;
}
}
for (var rateVal of ratesArr) {
ProductList.id = "Additional Charge Per KWH: " + rateVal.name;
ProductList.quantity = 1;
ProductList.bomType = "Manufacturing";
ProductList.orderNumber = 2;
ProductList.price = rateVal.rate;
ProductList.notes = rateVal.measure;
ProductList.parentProduct = "electricBillEstimator";
ProductList.next();
}
}
return ProductList;