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

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

0 1 687
1 REPLY 1

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 (https://hkrtrainings.com/salesforce-cpq-tutorial)When 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";