The On BOM Response enrichment
Summarize
Summary of The On BOM Response enrichment
The On BOM Response enrichment allows for dynamic manipulation of ProductList items in response to updates in the bill of materials (BOM). Enabled by default, it enables customers to adjust product pricing and attributes based on specific conditions or external data interactions.
Show less
Key Features
- Dynamic Pricing Adjustments: Automatically modifies product prices in the ProductList during BOM updates, using scripts to implement percentage changes or external pricing data.
- External API Integration: Can request data from external REST services to inform pricing decisions, enhancing the accuracy of pricing based on customer-specific information.
- Two BOM Versions: Distinguishes between the rules engine BOM and the enriched BOM to prevent infinite loops during updates and ensure efficient processing.
- Conditional Changes: Adjusts product attributes based on conditions such as quantity thresholds or specific product identifiers.
- Item Removal: Capable of removing line items from the BOM as needed.
Key Outcomes
By utilizing the On BOM Response enrichment, ServiceNow customers can expect:
- Enhanced control over product pricing strategies, leading to improved profitability and customer satisfaction.
- Greater flexibility in managing product attributes based on real-time data and conditions.
- Streamlined BOM updates that reduce the risk of processing errors and inefficiencies.
- Improved integration with external systems for a more robust pricing strategy.
You can use this enrichment to work with ProductList items whenever there is an update to the bill of materials.
The On BOM Response enrichment is enabled by default in environments and can be used to manipulate items in the ProductList whenever there is an update to the bill of materials (BOM).
In the following sample, the On BOM Response enrichment loops through products and changes the price of a product.
//Loop over products and change price of a product
let dealProduct = cfg.blueMoonSelected;
if (dealProduct == true) {
for(var prod of ProductList) {
let price = prod.price * .8;
prod.price = price;
}
}
On BOM Response enrichments may request external REST services via GET or POST.
In the following sample script, the On BOM Response enrichment uses an external connection to query a powerPricing API with customer data. With the customer-specific rate data retrieved from the service, the enrichment adjusts the pricing of existing ProductList records.
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;
The difference between the rules engine BOM and the enriched BOM
There are two versions of the BOM during runtime: the rules engine BOM, which is based on the results of product rules during runtime, and the enriched BOM, which is the result of the BOM enrichment.
The BOM enrichment's ProductList object (referenced in the script) is the result of the rules engine BOM, not the enriched BOM. This is to make sure there are no infinite loops. Suppose that the script were to reference its own ProductList that it returns, and the script were set up to increase the price of certain objects by a percentage on BOM update. In this case, the next time the contents of the BOM were updated, the price increase would happen again and again.
To prevent this situation, the enriched BOM is not referenced by any rule or enrichment other than the validation enrichment's ProductList. While this makes sure that the BOM enrichment can function outside the rules engine, it also means that if a condition is met in the BOM enrichment, those conditions can be met again the next time the BOM is updated, because any change to the BOM in the BOM enrichment script that stops that condition will not be referenced.
With external connections, this is not a problem as long as the response is consistent. However, if the response changes when fired multiple times, such as when generating a string or saving a certain time, it will update each time the BOM is updated.
The BOM Response enrichment might be used to:
- dynamically change the price of products in the BOM. This can be either a static or dynamic change rate, such as a shipping fee being static and taxes being dynamic.
- change attributes of products in the BOM that are reliant on some condition in the BOM, such as the quantity of free stickers given out once $100+ of tax has been quoted.
- remove a line item from the BOM.