Getting Started with Process Builder – Part 77 (Auto Add Products to New Opportunity)

Getting Started with Process Builder – Part 77 (Auto Add Products to New Opportunity)

Last Updated on December 6, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

How do you automatically add products to a new opportunity? 

Once Sales Reps create a new Opportunity, the next step is to add the Price book and products to it. Products are physical goods or services that you sell to customers. Your Sales reps can use products to generate sales quotes, contracts, or orders. Price Book is a catalog in which the regular selling price of products is listed. Price books are used for selling products at different prices based on geography, volume, government contracts, not-for-profit clients, strategic clients, etc.

In Salesforce, one product can be associated with multiple Price Books, and one Price Book can have multiple products. Yes! You are right! This calls for a Junction object. And, lo and behold, we have one known as Price Book Entry! Price Book Entry is a junction object between Product and Price Book, as shown in the following screenshot: 

 

This blog is a sequel to my previous blog Getting Started with Process Builder – Part 14 (Automatically assign Pricebook based on Opportunity Record Type)In the previous blog, I discussed how to automatically assign price book based on the Opportunity record type. I received tons of requests to write another blog about how to add a few default products to the new opportunity

So, here it is!

Prerequisite

  1. First, create two Price books Manufacturing and Retail.
  2. Add a few products to the Manufacturing price book as shown in the following screenshot:
  3. Please go through this article first and make sure to complete the listed stepsGetting Started with Process Builder – Part 14 (Automatically assign Pricebook based on Opportunity Record Type)

Business Use case

Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC) He has created a process using Process Builder to automatically assign Pricebook to new opportunity based on record types, as mentioned below: 

  • If the Opportunity record type is Manufacturing then assign a price book Manufacturing
  • If the Opportunity record type is Retail then assign a price book Retail

It’s working well, and Sales reps are happy. However, Martin received another requirement from VP of Sales when Manufacturing Price Book is added to a newly created opportunity, automatically add the following products to it:

  • iPhone 7 – Quantity (3) – Sales Price ($0)
  • iPhone 7 Plus – Quantity (3) – Sales Price ($0)

Automation Champion Approach (I-do):

The requirement is interesting. So, we will not only create a solution for the existing requirement – using Process Builder – but, we will also plan ahead! In my next blog, I will show you how Martin can avoid re-modifying the process again and again as and when the requirements change.

Create custom labels to store Price book-entry Id of default products

  1. First, run the following query (Select id, Name from pricebookentry where name IN (‘iPhone 7′,’iPhone 7 Plus’) and Pricebook2Id=’01sB00000006aeb’) in the developer console to get the PriceBookEntryID for iPhone 7 and iPhone 7 Plus, as shown in the following screenshot: 
  2. Click on  Setup (Gear Icon) | Setup | User Interface | Custom Labels.
  3. Click on New Custom Labels; it will open a new window for you. Now, create new custom labels to store the product (iPhone 7 and iPhone 7 Plus) Ids, as shown in the following screenshot: 
  4. Repeat the above process if you want to add more default products to the newly created opportunity.

The next step is to create a process builder to solve the requirement. Instead of creating a new process for this requirement, we will clone the existing process builder. 

Cloning existing Process

  1. Let us clone the process we created in part 14. Click on the Clone button available on the button bar. It will open a popup for you. Under Save Clone As, select Version of current process option. It will look like the following screenshot:
  2. Once you are done, click on the Save button.
  3. Now we will add the criteria for Manufacturing record type:
  4. Now you can modify the process as per the business requirement. In our case, we will add two immediate actions to add two default products (iPhone 7 and iPhone 7 Plus).
  5. The next step is to add an Immediate action under the Manufacturing criteria node to add the product iPhone 7. For this select Action, Type Create a Record, Use Field Picker to map the fields, as shown in the following screenshot:
    If you do not know how to use Custom Label in process builder then, consider reading this article Just Say no to hard-coded ID
  6. Repeat the above step, and add one more Immediate action under the Manufacturing criteria node to add Product iPhone 7 Plus. It will look like the following screenshot: 
  7. Once done, click on the Save button. This will redirect you to Process canvas. Finally, the Process will look like the following screenshot

Don’t forget to active the Process by clicking on the Activate button.

Proof of Concept

From now onwards, if a business user creates an Opportunity with record type Manufacturing, then, then Process Builder will automatically add price book and products to it.

  1. Navigate to the Opportunity tab, and create a new opportunity for the Manufacturing record type.
  2. Once done, click on the Save button. The process will automatically add the Price book and default Products to it, as shown in the following screenshot:

Formative Assessment:

I want to hear from you! 

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

Make a post and tag me on Twitter @automationchamp, using #AutomationChampionPB.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

13 thoughts on “Getting Started with Process Builder – Part 77 (Auto Add Products to New Opportunity)

  1. We have something similar built to auto create the renewals from closed won opps and bring over related fields and products. The issue we haven’t solved for is the quantity field where we want to bring over whatever the quantity listed was instead of just the default of 1 or whatever number we put in. Any chance you’ve covered this in a help article on flows? I’ve been looking but everything I see is pre-2018 and just sets default field values instead of cloning what was listed…thanks!

  2. Unfortunately get message “versions 3.0 and higher must specify pricebook entry id, others must specify product id”.
    Any suggestions of how tro avoid having to harcode the PBE ID into the process

        1. just because in Product ID You could have given Name while this is ID so please give Product ID

          in Criteria Add iPhone 7

          Field* Type* Value*
          Product ID ID 01t2w000000hU4M

  3. This work Perfect when we execute the apex code manually. But If I want Automatic to extract the PriceBookEntryID for Product and assign it to the Opportunity. Because I have name of Product and PriceBook. And using that I want to add that product to Opportunity

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.