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

1 Answer 1

up vote 2 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

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.