CPQ. am I right?
It’s fun enough doing out-of-the-box implementations but what happens when even CPQ isn’t enough?
Well good news everyone because Salesforce is back at it again with the new and improved CPQ plugin framework – https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_plugins.meta/cpq_dev_plugins/cpq_plugins_parent.htm
With our newfound knowledge, let’s write a pricing engine of our own. In our example we are going to give a discounted rate to products that are purchased during a certain weekend after the User clicks the ‘Calculate’ button in the CPQ line editor.
We need to note a few things here, the most important being how we interact with the quoteLineModels, to read fields from the record we need to use ‘line.FIELD_NAME’, when editing the record, we need to use ‘line. Record[FIELD_NAME]’ as they only this ‘record’ is editable to the plugin.
The other things to note are that the variables are all hard coded within the code, of course in a real scenario this information would be stored in records or statically within Salesforce.
Now we need to deploy our new pricing engine to CPQ, in order to do this please follow these steps:
- Login to the CPQ org
- Go to Setup
- Search for ‘Installed Packages’ and click the ‘configure’ button next to SalesforceCPQ
- Click the ‘Plugins’ tab, find the ‘Quote Calculator Plugin’ field on the lower right side
- Type in the name of your plugin like ‘ProductPricer’ or ‘PromotionEngine’, this will be needed for later as we’re going to create a record in Salesforce with the same name
- Click Save, then on the App Launcher and search for ‘Custom Scripts’
- Create a new Custom Script record, only 1 of these records may exist in the org
- Paste the name you chose to call your Plugin in step 5 into the Name field
- Fill in Quote Line Fields with a list of Fields referenced within your code, in our case put SBQQ__ListPrice__c
- Click Save
To test it, head over to a Quote record and click ‘Edit Lines’, add a product and then click ‘Calculate’, you’ll be able to see the list price update minus 25 (but be warned, this page likes to cache data!).
Congratulations, you’ve created and deployed your first CPQ plugin!
Thanks for reading,
The Tether Team
#salesforce #salesforcecrm #tethertips #tether #cpq #plugins