I set up a simple CPQ Javascript Quote Calculator Plugin Custom Script last week and it was working fine. Today, I wanted to update the script, but my changes don't seem to take effect.

My (simplified) custom script is as follows:

export function onAfterCalculate(quote, lines, conn) { console.log('onAfterCalculate 4'); return Promise.resolve(); }

The name of the Custom Script is: SAPPricing.

In the CPQ Settings Editor -> Plugins -> Quote Calculator Plugin, I have specified the name of the Custom Script: SAPPricing.

However, when I run it, the Console Log outputs 'onAfterCalculate' which was specified in my previous version of this Custom Script.

I have tried running it in different browsers and I keep getting the output from the previous version of the script. It seems like the old script is cached on the server and won't update.



Update: I was able to modify it this morning, but after a couple of simple modifications, my updates to the Custom Script no longer are showing up when I perform calculate again.


I've seen this happen when there is an issue in the Javascript. CPQ transpiles the code you paste into the script. I've found that first pasting my plugin code into https://babeljs.io/repl and checking for errors, helps ensure there are no issues.

There is a field on the Custom Script object called Transpiled Code. You can also check that it gets updated after saving your changes.

Edit: There is a Visualforce page you can add to your Custom Script page layout called Custom Script Save. It will tell you the Transpiling status.

page layout with VF page

transpiling status

|improve this answer|||||
  • Thanks. Have been using VS Code with the Salesforce CPQ - Quote Calculator Plugin and assuming that this would show any syntax errors. Will also checking the Transpiled Code field to see if that correlates with code not getting updated. – Mike Paisner Jan 16 '19 at 20:22
  • Transpiled Code gives me a good view of whether my edits have been accepted or not. However, if they haven't been accepted, I still have no other way to fix it except for cloning the Custom Script object. Tried babeljs.io/repl on some code that was not transpiled, but it showed no errors. Bottom line is I am still cloning Custom Script alot, but at least I have a work around. – Mike Paisner Jan 16 '19 at 22:12
  • I just found that there's a visualforce page you can add to your page layout that will tell you errors if there are any. Is that on your page layout? – Daniel Hoechst Jan 17 '19 at 15:59
  • Also you can try clearing the Transpiled Code field. – Daniel Hoechst Jan 17 '19 at 16:07
  • 1
    VF page is already on page layout. I turned on the label of VF Page to verify that it is there. Tried introducing error into my Javascript code intentionally and I do get an error similar to what you displayed. However, when I remove my intentional error, I get the same behavior I have been seeing - no error is displayed in VF Page, but it doesn't transpile either. If I save my code in classic, I can see VF Page briefly show the word "Transpiling" and then it completes without error, but transpiled code is not updated. Weird, because if I clone code to new record, it transpiles and runs fine. – Mike Paisner Jan 17 '19 at 17:42

It seems the only reliable way that I can make updates is to:

  1. Clone the Custom Script.
  2. In the in the CPQ Settings Editor -> Plugins -> Quote Calculator Plugin, specify the name of the cloned Custom Script.
  3. Exit the Edit Lines window and navigate back in.

Directly editing the Custom Script works sometimes, but no reliably.

I have an open case with Salesforce, but no response from them yet.


|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.