Skip to main content

Salesforce CPQ - Automatically add a Product to a Quote

Recently I have seen a question popping up on communities that how can we add a product dynamically to a quote (not within the bundle), based on a condition. I'll explain a few simple use cases below.

These use cases refer to adding a product on a Quote Line Editor and the CPQ version installed is 214.6

Add a "Warranty" Product if "Macbook Pro" is added to the Quote.

While I select "Macbook Pro" to add in my Quote, it should also add the "Warranty" product automatically to my Quote.

1. Product Rule: Create a Product Rule of type Selection and scope equals Quote. 


  • Type: Selection
  • Active: checked
  • Conditions Met: All
  • Scope: Quote
  • Evaluation Event: Always
2. Error Condition: Add an error condition to the Product Rule. This product rule will run if this error condition returns true. As per the use case, it should run if there is a product added to the Quote with a Product code as "MBPRO"



  • Tested Object: Quote Line
  • Tested Field: SBQQ__ProductCode__c
  • Operator: equals
  • Filter Type: Value
  • Filter Value: MBPRO
3. Actions: If the condition returns true, we would like to add the Warranty product to the quote, add an action to do so.


  • Product: Warranty
  • Type: Show & Add
Note that another version of the use case above can be to add a Warranty Product if an "Add Warranty" checkbox on Quote is checked i.e. add a product based on a field value on Quote. To do so the error condition above will be modified to these values:
  • Tested Object: Quote
  • Tested Field: Add_Warranty__c
  • Operator: equals
  • Filter Type: Value
  • Filter Value: TRUE 

Add a linked product on the Quote

If there are a lot many different linked products to be added, creating one product rule for each is not recommended rather a Lookup table should be used to achieve that.

1. Lookup Table: Create a lookup table with the master product and a linked product. In our use case, Macbook Pro is the master product and Warranty is the linked product. I have added 2 sample records in this object:


2. Product Rule: Create a product rule referring to this lookup table:


populate the lookup query information from the custom object.

3. Lookup Query: add a lookup query related to the product rule above.


  • Match Type: Field Value
  • Tested Object: Quote Line
  • Tested Field: Product Code
  • Operator: equals
  • Lookup Field: Master_Product_Code__c





Comments

Popular posts from this blog

Autocomplete Lookups for Salesforce1

We all are seeing that Salesforce1 is evolving with every passing day and there is yet lot to be done. One of the many items is a custom lookup field on a Visualforce page. Lightning design systems do provide us with the CSS we can use to create lookup fields the logic has to be written by the developer. Below is a basic example that can be used to implement the basic autocomplete version of the lookup field. The auto complete text box is implemented using the CSS provided by Salesforce1  lightning design . The Visualforce page uses Visualforce remoting to fetch records based on the user input. A call to the controller method is made every time a keyup event is fired and the results are updated.

Exporting Files/Attachments from Salesforce

While working on a Salesforce migration project where I was asked to export a set of attachments from one Salesforce Org to another, I developed this tool. The customer had millions of attachments in their source Org and only a few thousands had to be migrated. What are the existing options in the market? Few of the existing options suggested by different people were: Use Weekly Export. I could use it but I only had to export a few thousand attachments from millions and I can only run it once a week. Use dataloader.io. The free version only allows me to extract limited records on a day. Where can I download this from? I developed a JAR file which did the job for me and wanted to share it with everyone.  Download URL: https://www.crossdoor.io/sfdcfiles/ There are 2 files build.properties SFDCFiles.jar First step is to setup build.properties with the Org credentials and SOQL to extract data from. How to run this? To run this Jar file execute the below command on yo