Customizing Pricebook entries in Salesforce
Price Book Entry
- In Salesforce.com, Pricebook entry object acts as a junction object between Pricebook and Products. In Winter14, there was no feature for customizing your Pricebook entry. From Summer14, you can customize your Pricebook entry.
- In Salesforce.com, there are two types of Pricebook entries are available. Such as,
- Standard Pricebook entry
- Custom Pricebook entry
- Standard Pricebook entry represents default prices for the products that are sold.
- Custom Pricebook entry represents list prices for the products that are sold. Without adding the product to the Standard Pricebook, we cannot add it to Custom Pricebook and also the particular Pricebook should be active.
To learn more about PriceBook entry follow this link: Salesforce Price Book Entries Overview
Customize your Pricebook entry
- In summer 14, Salesforce.com enhanced Pricebook entry, in such a way that a user can create fields, Page layouts, Validation rules, field sets, and search layouts available for customization in Pricebook entry object.
- Data migration can be done easily, as we can create custom fields (Using External Id).
- Maximum number of custom fields in Pricebook entry is 50. When you delete a custom field that is used in any view for filter purpose, then the result of the view will be changed. Also, the result of Assignment and Escalation rules will get changed.
Once you created your custom Pricebook and products, you can view the detail of the Pricebook entry.
Then, click the view link in your products related list. Then, you see the particular Pricebook entry in the detailed page.
Usage of Pricebook entry in Test Class:
- With the summer14 release, we don’t need to use @isTest (SeeAllData=True) annotation in test classes related with PriceBook entry.
- Before summer 14, we must use @isTest (SeeAllData = True) annotation in your test class.
If you need to learn about this follow the Url : Using Salesforce PriceBook Entry in Test Class.
Public class PriceBookEntryTestClass
Public static void createNewPriceBookEntry()
PricebookEntry pricebookent = new PricebookEntry();
Product2 product = new Product2();
product.Name = ‘Samsung GT-7582′;
Pricebook2 pricebook = new Pricebook2();
pricebook.Name = ‘Samsung Galaxy PriceBook’;
pricebookent.Product2Id = product.Id;
pricebookent.Pricebook2Id = pricebook.Id;
pricebookent.UnitPrice = 9000.00;
pricebookent.IsActive = true;
Price book Entry customization makes data migration easy, and optimizes the Test class usage.