function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cbrocbro 

Limit Opportunity Product Selection by Opportunity Record Type

How can I limit Opportunity Product Selection to a specific Record Type?

Can I do this with Apex Code, or would this be Visualforce?

For example:
  • For Record Type A, Products 1,2, and 3 should be available to select.
  • For Record Type B, Product 4 only should be available to select
  • For Record Type C, Products 1,4, and 5 should be available to select.
Thanks in advance for any help.
cbro

I saw this post (here (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AcxbIAC)), which may help, but any other help would be greatly appreciated.
Best Answer chosen by cbro
SonamSonam (Salesforce Developers) 
You would have to create a VF page together with a controller to get a list of   products that you would map with the given opportunity Record type.

As is shown in the thread you mentioned, the code automatically adds certain products to the opportunity at the time of creation, however, this is automatic.

If you wish to restrict the products the user should be able to see when trying to add to an opportunity depending on its record type - you will have to customize the "add Product" page and show user only the relevant products.

This will need both VF and controller.