Is there a way to identify what action started QCP Calculator Plugin script in Salesforce CPQ?

  • 29 July 2022
  • 1 reply

I'm using a JS script as a plugin for QCP calculator to do some stuff after every change in Quote Edit Lines.

Quote Edit Lines

Now I need to run the part of the script only when user presses Calculate or Save button. The only way I see is to somehow find out in the script, what was the reason of this script to run (did user press Calculate or Save button or did he edit any field so the script started). Script functions have 3 params: quoteLineModels, quoteModel, conn; I've investigated the difference between these objects when user pressed Calculate button and when user edited any field not changing the value (e.g. from 150 to 150) and found no difference

Calculate Immediately

Unchecking Calculate Immediately checkbox in CPQ package settings is not a solution - I need this checkbox for other calculations, not for the script

1 reply

The biggest difference between the two is the location that the script executes. When the user is in Edit Lines, then the QCP runs in the browser confined to Salesforce CPQ ( it executes due to a trigger, it runs in Heroku. Perhaps you can check to see if window is defined or not.

I'm unable to test to see if this works, but you could try something like

const isBrowser =
typeof window !== "undefined" && typeof window.document !== "undefined";