Salesforce CPQ — How to restrict users from adding duplicate Bundle in Quote?

Tejas Kapasi
2 min readDec 27, 2020

--

I am pretty new to salesforce CPQ and recently I came across the challenge to add the restriction of adding duplicate bundle products in the Quote. I found classic use of Javascript Quote Calculator Plugin.

Requirement:

Users should be able to add as many different bundles to the cart. But the cart shouldn’t have the same bundle lines. When a user is trying to save the cart they should be seeing the error message.

Solution:

As this can’t be directly achieved via simple product rule configuration, we have to use Javascript Quote Calculator Plugin.

Read more about — Javascript Quote Calculator Plugin.

Logic to Implement:

  • Check all the bundle lines in the quote and see if there’s any duplicate bundle line. If there’s any duplicate line found then set a flag on the quote object which indicates duplicate found.
  • To reset the flag every time we calculate or try to save the cart.

Steps to implement:

  1. We need to have a custom field on the Quote object. Create a checkbox field on quote names isSameOfferingAdded__c.
  2. Implement onBeforeCalculate a Javascript Quote Calculator Plugin as below:
Custom Quote Calculator Plugin

3. Go to the Custom Script tab and create a new record as below:

Custom Script Record

4. Add this callback to the CPQ setting. (Setup->Installed Package -> Click Configure against Salesforce CPQ)

CPQ Setting

5. Now, Create a Product Rule that uses the checkbox “isSameOfferingAdded__c” to display an error message when the user clicks quick save/Save buttons in the cart.

Validation Product Rule

We’re done with the implementation, Let’s have some showtime!

Thank you for reading this post, if you are interested in more content please visit http://sfdcsharepoint.com and do comment about this article.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Tejas Kapasi
Tejas Kapasi

Written by Tejas Kapasi

6X Salesforce Certified, JDF18 Speaker, Lightning Champion, 4X Ranger

Responses (1)

Write a response