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

    sfdcsharepoint.com
    Image shows the validation rule on cart page

    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:

    Logic to Implement:

      n

    • 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.
    • n

    • To reset the flag every time we calculate or try to save the cart.
    • n


    Steps to implement:

      n

    1. We need to have a custom field on the Quote object. Create a checkbox field on quote names isSameOfferingAdded__c.
    2. n

    3. Implement onBeforeCalculate a Javascript Quote Calculator Plugin as below:
    4. n

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

    nn

    Record creation in Custom Script

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

    n

    Salesforce CPQ Settings

    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.

    nn

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

    nhttps://www.youtube.com/watch?v=o5QVpf4oais&feature=youtu.be


    Thank you for reading this post!

    Leave a Reply

    Your email address will not be published. Required fields are marked *