+ Start a Discussion

Look up

I created a custom object and I tried to create a look up field to connect to a standard field called Opportunity Product. Is there a way to do this? I want to use the product pick list in Opportunity Product in this custom object I created.

Andy BoettcherAndy Boettcher

Declaratively, you can't do this.  Opportunity Product isn't an available Lookup target.


You could use Product - sounds like that may be what you're going for anyways?




Hi Andy,


I was wanting use the pick list that is created on the "Opportunity Product" that is linked through Opportunity. I guess I need to look for some Visual Force coding to create something that is simular.


Thanks you,



Instead of opportunity Product , fetch Price book entries and populate it in the picklist.


Because any how Price bbok entries has to used to create Opprtunity product.


for example you can use Pricebook name to fetch PBE (Price book name can be configure)




private void populateProductPickList(){
products = new List<Selectoption>();
for (PricebookEntry pricebookEntry : [Select p.ProductCode, p.Product2Id, p.Pricebook2Id, p.Name, p.Id From PricebookEntry p where p.Pricebook2.Name=:PRICE_BOOK_NAME]){
products.add(new SelectOption(pricebookEntry.Id,pricebookEntry.Name));





<apex:outputPanel styleClass="requiredInput" layout="block" >
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:selectList id="productNameValue" disabled="false" multiselect="false" value="{!productDetails.oli.pricebookEntryId}" size="1">
<apex:selectoptions value="{!products}" />


Thank you so much for your help. I am new so be nice when I ask can you help me with a step by step process?


Tht's fine


Where would I put this code? Object Page?