0

Since there is no way to use summary variables or roll up summary fields or price rules on quote line groups, I was wondering if there is to way to write a custom QCP that calculates the NetTotal for each quote line group with a specific condition. That condition would be only the quote line items in the group where subscription type = "One-time".

  1. For each quote line group, loop through each quoteline and sum the net total to store in a variable
  2. Update custom quote line group field with that variable value.

Update here is below code I have in a custom script record...however it does not seem to update my Quote Line Group field. I don't receive any errors.


function calculateOneTimeProductsTotal(quotelineGroup) {
   var oneTimeProductsTotal = 0;
   quotelineGroup.getQuotelineItems().forEach(function(quotelineItem) {
   var product = quotelineItem.getProduct();
   var subscriptionType = product.get("Subscription_Type__c");
   if (subscriptionType === "One-time") {
   oneTimeProductsTotal += quotelineItem.get("SBQQ__NetTotal__c");
}
});
quotelineGroup.set("One_Time_Services_Total__c", oneTimeProductsTotal);
}

function calculate() {
var quoteModel = window.quoting.model;
var quotelineGroups = quoteModel.getQuotelineGroups();
quotelineGroups.forEach(function(quotelineGroup) {
calculateOneTimeProductsTotal(quotelineGroup);
quotelineGroup.on("change:quotelineitems", function() {
calculateOneTimeProductsTotal(quotelineGroup);
});
});
}

1
  • Have you found a solution yet? Commented Oct 22 at 13:49

0

You must log in to answer this question.

Browse other questions tagged .