Thursday, August 18, 2011

Loading products , pricebooks and pricebook entry

There is always a need to load Products into salesforce. Its a 3 step process to load products and associate them with pricebook . There is a standard pricebook which salesforce provides by default which can be deactivated. There is also an option to create custom pricebook as many as you want in accordance with the business.

Fields in red are required and fields in blue are read only

Pricebookentry is the junction object between product2 and pricebook2 object( For strange reasons they have suffix 2 for standard object) . It has lookup for product2 and pricebook2 field through product2id and pricebook2id field. Name and productcode is copied over from product2 based on product2id field.

Essentially for loading Products you need to load product2 table first. Create a CSV file. Name is the only required field. Optionally have columns for other fields indicated in the pic.set Isactive to true. use dataloader to insert data. Get the id of the products from success file which got created.

Pricebook2 will also have only Name as required field. Isstandard indicates whether its a standard or custom and its readonly. Also Isactive should be set to true if you are planning to use it. Get the Pricebook2id from success file. Alternatively export pricebook2 table to get id of pricebook already created.

Final step is to create pricebookentry. Pricebook entry needs to be created for each Pricebook.
populate ids of product2 in product2id column and pricebook2 in pricebook2id column. Unitprice is a required field where the price for this pricebook is set. Pricebook entry for a custom pricebook cannot be made if that product is not there in the standard pricebook.

Unitprice can be made read only if usestandardprice field is set to true. This can be made only for custom pricebook and when the product is added to standard pricebook. So the unitprice set in standard pricebook will be carried over to the custom pricebook. Make Isactive true whenever u are planning to use it. Use dataloader to insert the pricebookentry. you have to repeat the above 2 steps for each custom pricebook.If you have multiple currencies enabled there should be as many pricebook entry records for a single product in a pricebook for each currency.