Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Is it possible to set default pricebook based on recordtypes. We have recordtypes like sales and sevice. So when an user selects sales recordtype we should have sales pricebook as default and service pricebook as default if he selects service recordtype.

Is this possible?


share|improve this question
With an Apex trigger you would be able to do this. Is that an option? – Lex Feb 1 '13 at 7:37
Cant it be done through UI? If it cant then i am trigger happy :) – Prady Feb 1 '13 at 8:25

2 Answers 2

up vote 4 down vote accepted

Selected Pricebook is stored in Opportunity.Pricebook2Id.

I've quickly hacked a test and it works in my Dev. Edition so yo should be able to write a before insert, before update trigger?

List<Opportunity> opps = [SELECT Id, Name FROM Opportunity WHERE Id = '0067000000U5Wtc'];
opps[0].Pricebook2Id = '01s700000006j5TAAQ';
update opps;

The field is not listed in the setup but you can cheat by hand-crafting the url to it ;) No way to set lookup filters (hmm, maybe from Eclipse) but a validation rule - why not ;)


Last but not least - have you seen

enter image description here

share|improve this answer
Thanks @eyescream, just wanted to confirm that we cant say from UI that this recordtype should use only this pricebook? write trigger to update the pricebookid and to validate that users dont choose any other pricebook we write a validation rule. am i correct in my understanding – Prady Feb 1 '13 at 8:33
Something like that (I might have to do similar thing soon). Field can't be added to Opp page layout (maybe a formula would work if you want to display it?) and since it's technically data and not config thing - it's not selectable in record types config. – eyescream Feb 1 '13 at 9:09

Feels weird to answer a 2 year old question that already has a great answer, but since my search took me here, I figure others might see this too:

This is also now possible with Process Builder, for anyone who shies away from Apex. In my use case, I wanted to set a price book upon opportunity creation, but still allow users to have access to the other price books. Since I was also looking to add a base "package" of products to every opp, process builder was my first thought over Apex. Works well -- I may flip it to a trigger eventually so I can do some more advanced manipulation of revenue schedules, but for now, this got the job done! Definitely bookmarking eyescream's answer as well, though!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.