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
shawnjcloseshawnjclose 

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?

 

-Andy

shawnjcloseshawnjclose

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,

Shawn

abhishektandon2abhishektandon2

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)

 

Apex

========

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));
}

}

 

VF

==

<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}" />
</apex:selectList>
</apex:outputPanel>

shawnjcloseshawnjclose

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?

abhishektandon2abhishektandon2

Tht's fine

shawnjcloseshawnjclose

Where would I put this code? Object Page?