Process Builder Showcase: Assign a Price book based on Opportunity Record Type

Share this article...

Price book is a standard Salesforce object that enables you to store the prices of products. You might create multiple price books when the standard prices vary, for example, if they are modified for different types of products, vendors, or customer groups. Typically your users would select the price book, however in some situations it makes sense for the price book to be automatically selected based on certain criteria.

In this article, I am going to show you how to automatically assign the Price book based on the Opportunity record type using Process Builder.

“Gearset”

Setting the Scene

I am working as a Salesforce Administrator and have received a requirement to automate price book assignment based on the Opportunity record type:

  • If the Opportunity record type is B2B then automatically assign a price book B2B
  • If the Opportunity record type is B2C then automatically assign a price book B2C

Before you start creating in Process Builder, it’s best that you understand the Opportunity object, fields and relationships.

Tip: I suggest you create and test this process in your sandbox first, then move it to Production.

Step 1: Get the Pricebook ID

First we have to locate and save (keep a note for later) of our Pricebookid from each price book. To locate the Price book ID’s, open each price book record and copy the ID from the URL. It will look something like 01s7F00000KM5ZsQAL, as shown in the screenshot below:

Repeat for your other Price book (B2C Price book).

Step 2: Create a Process Builder

Go to Setup → Find Process Builder from the quick find box → click New.

Enter the necessary details:

  • Enter Process Name (the API name populates automatically).
  • Description (Optional).
  • Choose The Process starts when “A record changes” → Save.

Add entry criteria:

  • Click Add Object → Select Opportunity object.
  • Start the process → only when a record is created → click Save.

Next, add process criteria for record type B2B. Enter criteria name B2B Criteria for Executing Actions is Conditions are met.


Set Conditions, by clicking into the Field box to launch the list of fields. In this case I have selected [Opportunity].Record Type ID → Name → Choose.

Once you click Choose, it will look like the screenshot below:

Make sure your Operator is set to Equals and Type is set to String. In Value enter B2B.

Click Save. It will look like the screenshot below:

Next, add an Immediate action to the Process for Record type B2B.

Click Add Action (underneath ‘Immediate actions’) → Select Action Type equals Update Records → Put action Name B2B Price book → Click Record Type → Click Select the Opportunity record that started your process → Click Choose.

Next, enter criteria to update the record. In our case we choose No criteria-just update the records! From Field find Price Book ID → Type ID → Enter the B2B Price Book ID, that we took in step 1 01s7F00000KM5ZsQAL (your ID will be different!) → Click Save.

Next, add another set of Criteria and Actions for our B2C record!

Click Add Criteria → Criteria name B2C ** Criteria for Executing Actions is Conditions are met.

Set Conditions, by clicking into the Field box to launch the list of fields. In this case I have set [Opportunity]. Record Type ID → Name → Click Choose.

Once you Click Choose, it will look like the screenshot below:

Make sure your Operator is set to Equals and Type is set to String. In Value enter B2C.

Click Save. It will look like the screenshot below:

Next, add an Immediate action to the Process for Record Type B2C.

Click Add Action (underneath ‘Immediate actions’) → Select Action Type equals Update Records Put action Name B2C Price book → Click Record Type → Click Select the Opportunity record that started your process → Click Choose.

Next, enter criteria to update the record. In our case we choose No criteria-just update the records! From Field find Price Book ID Type ID Enter the B2C Price Book ID, that we took in step 1 01s7F00000KM5ZxQAL (your ID will be different!) Click Save.

Final step is to Activate our process Click Confirm.

Step 3: Testing

All done! We have activated the Process Builder and are now ready to test our new process. Check out the video below:

Summary

In this article, we have covered how to easily add a specific price book based on Opportunity record type. Automating in this way can save your users lots of time and prevent them choosing the wrong price book by mistake!

3 thoughts on “Process Builder Showcase: Assign a Price book based on Opportunity Record Type

  1. Avatar

    While this would work, it is best practice not to hardcode Record Type Ids. For this reason I use Flow and use ‘Get Record’ to retrieve the RecordTypeId from the RecordType object.

  2. Avatar

    I have to check on this but I think that PB can use a formula to get the Price Book record type ID as it’s related to the Opportunity. I’ll do that and repost an update to confirm.

  3. Avatar

    I agree with Mark above (Hi Mark!). Instead of doing it with a flow, I do a custom metadata component, and it’s one of the devops steps that needs to be completed with a sandbox refresh. So instead of having to update the Pricebook ID in 124 different places, doing it in the custom metadata, and then referencing that data, saves time and ‘phantom’ ids.

Leave a Reply