In Salesforce, when a user creates an Opportunity record and adds a product to that opportunity, they must assign a price book to the product.
With the help of Salesforce flows, we can automate the assigning of price books to Opportunity products. In this Salesforce tutorial, we will learn to automatically assign PricebookId to Opportunities using Salesforce Flow.
While working as a Salesforce admin, I was assigned the task of automating the Pricebook assignment to the newly created opportunity record. Since the company had an annual price book for all products, the sales team wanted to assign that price book to new opportunity records automatically.
Automatically Assign PricebookId to Opportunities using Salesforce Flow
We will create a record trigger flow to auto-assign the Price book ID to opportunities, but before that, we need to create a Custom label that will store the ID of the currently activated price book.
Create a custom label for the price book ID
1. First, we will create a custom label using the activated current price book ID, and then we will use that label in the flow to do that on the setup page, search, and select Custom Label in the Quick Find box.

2. In the next window, click the New Label button.
3. Enter the below fields for the custom label.
- Enter the label in the Short Description field, and the Name will be auto-filled.
- In the Categories field, enter Automation.
- In the Value field, enter the ID of the Pricebookid that you want to assign to the opportunity.
- At last, click the Save button.

Create a flow to Auto-assign PricebookId to opportunities in Salesforce
To Create a flow to Auto-assign PricebookId to opportunities in Salesforce, navigate to the setup page and follow the below steps.
1. On the setup page of Salesforce, go to the Quick Find box and search then select flows under the heading Process Automation.
2. In the Flows setup window, click on New Flow.
3. Select the option Record Trigger Flow and click Create.

4. In the flow builder, configure the trigger conditions in the following way.
- Select the Object as Opportunity.
- In the section Configure Trigger, select the option A record is Created.
- In the section Optimize the Flow, select the option Fast field updates.

5. After this, add an Assignment element to the flow and enter the fields in the following way.
- Enter the Label and API Name for the Assignment element.
- In the section, Set Variable Values, select the Variable as Record > Price Book ID, and Value as Label > Current_Price_book (custom label).

6. Now save the flow with the relevant Flow label, and the Flow API Name will be auto-filled. After this, click the Save button.

7. At last, click on the Activate button to activate this flow.

Now, the flow is created. Now, we will test and debug the flow.
Debug and Test the flow
To debug and test the flow, navigate to the Opportunity tab and follow the below steps.
1. Create a new Opportunity record.
2. In the newly created Opportunity record, click on Add Products.

3. In this window, we will see the products of Pricebook that we have added to the flow.

In this way, we can assign PricebookId to Opportunities in Salesforce on record creation using a flow.
Conclusion
In Salesforce, automating the assignment of PricebookId to opportunities using Flow saves time and reduces errors in the sales processes. By following the above steps, you might have understood the process of auto-assigning PricebookId to opportunities in Salesforce in record creation using flow.
Here, we have created a custom label to store the price book ID and then used that label as the flow to automate the process of assigning price books to opportunity records.
You may like to read:
- How to Bypass Validation Rules Using Salesforce Flow
- How to Deactivate Standard Products in a Standard Price Book via Data Loader in Salesforce
- Auto-Assign Members to Account Team Using Salesforce Flow
- How to Import Order Products with Data Loader in Salesforce
- Screen with Two Columns in Salesforce Flow
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.