+ Start a Discussion
selvakumar Anbazhaganselvakumar Anbazhagan 

Assign Pricebook based on "Accounts" Zipcode

Hi Everyone,

I need the functionality that Pricebook should be automatically assign when a opportunity created(Account Should be mantatory). Account is being created based on the Zipcode. We have a field in Zipcode table as "Pricebook Name"(This is reffered from Pricebook table) .

For example, I have data from Zipcode table Zip=12345 and Pricebook_Name="US Pricebook"(It will be reffered from Pricebook table).
Account have created for the Zip '12345'. Now when i create a new opportunity to this account it should be assign "US Pricebook" automatically. How i can acheive this ? Is it a trigger or Validation rules or Lookup formula.?

Any help on this.

Thanks in advance.

 
logontokartiklogontokartik
You can write a trigger that will set the Pricebook on the Opportunity based on the Account Selected.
The field on Opportunity that is available via code is Pricebook2Id.

I haven't tried if you can do this via Process Builder, but if yes, thats the way to go to avoid code
 
Amit K AAmit K A

Please use "Pricebook2Id" field available on opportunityobject , and this can be done only by trigger.

and for account mandatory condition you may create validation rule or on pagelayout you can mark account field as required.