[SalesForce] CPQ – How to perform custom field calculations in Quote Edit lines screen


In Edit quote lines screen of Salesforce CQP, we need to add a custom field "Budget" and add a JS script to auto-calculate the additional discount % applicable on all the lines, so that the quote total is equal to the custom field "Budget" amount.

The additional discount % field must be editable to that user can still adjust the discount line by line.

enter image description here

Research done so far

For the budget field, we found that a custom field must be created on Salesforce CPQ Quote object and added to the appropriate field set used by CPQ package, so that it becomes visible on the CPQ quote edit line screen.

It is also understood that the calculation can be achieved by the Javascript quote calculator plugin.

But we are new to CPQ and documentation found so far is not clear enough to answer the questions below but maybe we are missing something.

Call a Custom Script in the Quote Calculator Plugin

Javascript Quote Calculator Plugin


  1. where do we write/save the script to perform the additional discount % calculations in the quote line table ?
  2. Any pointers to some documentation about how to go about writing such script ?
  3. What is the procedure to deploy CPQ custom JS script to higher environments (sandbox and production) ?

Any help is appreciated, thanks

Best Answer

  1. You need to create a Custom Script record with your QCP implementation and later go to the CPQ package settings and indicatr the Name of the script in the Calculator Plugin field in the configuration.

  2. In your second link to the documentation you can find pretty much everything, particularly in the Plugin Methods one, you need to implement the exported functions that apply for your use case by modifying the quoteModel or quoteLineModels that are passed into the method as arguments.

  3. Since the scripts are records from the Custom Script object you'll need to either create / edit your record manually in other environments or use mechanisms that ease data deployments such as SalesforceDX import commands

Related Topic