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!
- First, create two Price books Manufacturing and Retail.
- Add a few products to the Manufacturing price book as shown in the following screenshot:
- Please go through this article first and make sure to complete the listed steps: Getting 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
- 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:
- Click on Setup (Gear Icon) | Setup | User Interface | Custom Labels.
- 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:
- 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
- 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:
- Once you are done, click on the Save button.
- Now we will add the criteria for Manufacturing record type:
- 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).
- 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.
- 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:
- 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.
- Navigate to the Opportunity tab, and create a new opportunity for the Manufacturing record type.
- 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:
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.