Automatically Assign PricebookId to Opportunities using Salesforce Flow

In Salesforce, when a user creates an Opportunity record and adds a product to that opportunity while creating the record, they have to assign a price book to the product they add to the Opportunity record.

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.

Create Custom Labels in Salesforce flow

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.
Assign PricebookID to opportunity using flow in Salesforce

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.

See also  How to Create an Email Template In Salesforce Flow

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.

Assign Pricebook using flow in Salesforce

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.
Use flow to assign pricebook in Salesforce

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).
Use trigger flow to auto assign Pricebook id to Salesforce Opportunities

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.

Auto-Assign Price book ID to Salesforce Opportunities with flow

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

Automatically Assign PricebookId to Opportunities using Salesforce 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.

Use flow to assign pricebook in Salesforce Opportunities

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

Auto-Assign Price book to Opportunity Products in Salesforce

In this way, we can assign PricebookId to Opportunites in Salesforce on record creation using flow.

See also  How to Display Image in Salesforce Screen Flow


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-assign 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: