5

Salesforce wants me to choose a price book in order to add products to an opportunity, but our organisation has opted not to use price books because we never deviate from the standard price. However it appears I cannot add ANY products to an opportunity without creating a price book and adding them to that.

So I ask firstly is there any way to turn off this behaviour and just let opportunity use the standard price, and also if there is no way to do this what is the point of the standard price?

  • Yes you can do it using apex & visualforce page functionality by mimic Standard opportunity functionality – Bharat Apr 1 '14 at 15:07
  • Does anyone know if it is possible without building an almost identical version of something that otherwise works fine minus a feature or two? Salesforce really annoys me with little stuff like this sometimes because it means things that should be pretty simple often require a lot of needless work :/ – Adam Apr 1 '14 at 15:17
2

Any special reason why you can't have a small trigger?

trigger oppWorkaround on Opportunity(before insert, before update){
    for(Opportunity o : trigger.new){
        if(o.Pricebook2Id == null){
            o.Pricebook2Id = 'hardcoded id here';
        }
    }
}

Put the id of your standard pricebook and you're done (except developer sandboxes). Bit better way would be to waste 1 query to SELECT Id FROM Pricebook2 LIMIT 1.

You will still need to specify PricebookEntries for products you want to be selectable (but since you mention standard prices I assume you're aware of that).

| improve this answer | |
  • Thanks, I'll see about putting a trigger in there. What do you mean by except developer sandboxes though? Is there some limitation they have that will change how this behaves in a production org? – Adam Apr 2 '14 at 13:15
  • Hm... I'd swear the std. pricebook isn't copied over to dev. sandboxes but apparently it is :) Ignore that part then. Id will be the same in sandboxes and production. You'll still need to change the Id if you'll want to reuse this code in completely different environment (Developer Edition for example). – eyescream Apr 2 '14 at 14:44
1

Found out how it is possible. I just hadn't activated the standard price book. For anyone reading this question looking for an answer go to Products, then find Manage Price Books down in maintenance at the bottom, then navigate to Standard Price Book and either click activate on the search results or click to get to its detail page and check the Active field. This will cause it to be selectable when adding products to opportunities.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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