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
dev33dev33 

opportunityLineItem.PricebookEntry.Name = null

Controller

System.debug('opportunityLineItems ------------------'+opportunityLineItems);
for(OpportunityLineItem opportunityLineItem:opportunityLineItems){
System.debug('opportunityLineItem------------------'+opportunityLineItem);
System.debug('PricebookEntryId------------------'+opportunityLineItem.PricebookEntryId);
System.debug('PricebookEntry Name------------------'+opportunityLineItem.PricebookEntry.Name);

}

 

VF

<apex:pageBlockTable value="{!OpportunityLineItems}" var="item" headerClass="headerRow" rowClasses="odd even">
<apex:column value="{!item.PricebookEntry.Name}" headerClass="headerRow" headerValue="Deal Products" />
<apex:column value="{!item.PricebookEntry.ProductCode}" headerClass="headerRow" headerValue="Part Number" />
<apex:column headerClass="headerRow" headerValue="QTY" value="{!item.Quantity}"/>
<apex:column headerClass="headerRow" headerValue="MSRP" value="{!item.ListPrice}" />
</apex:pageBlockTable>

dotnet developedotnet develope

Hi,

 

My first question, have you mention the field name in that query define inthe controller?

 

if yes, please post the controller class.

 

 

KalluruKalluru

Thanks For replaying my complete problem

 

I have opportunityID and priceBookID ,I need to display the ProductName,ProductCode,Quantiy and Price in VisualForcePage.

In controller 
I got the List of pricebookEntry for the given priceBookID
I added the List of pricebookEntry to List opportunityLineItem for given opportunity.
But when I try to get the opportunityLineItem.PricebookEntry.Name in Controller I am getting Null Value
In VisualforcePage {!item.PricebookEntry.Name} I am getting null value.

Controller 

List<PricebookEntry > pricebookEntrys = [Select id,ProductCode,UnitPrice,UseStandardPrice,Name from PricebookEntry where pricebook2ID =: priceBookID];
List<opportunityLineItem> opportunityLineItems = new List<opportunityLineItem>();
System.debug('------------------------pricebookEntrys Size='+pricebookEntrys);
for(PricebookEntry pricebookEntry:pricebookEntrys){
OpportunityLineItem opportunityLineItem = new OpportunityLineItem();
opportunityLineItem.OpportunityId = opportunityID;
opportunityLineItem.PricebookEntryId = pricebookEntry.Id;
opportunityLineItems.add(opportunityLineItem);
}
System.debug('opportunityLineItems ------------------'+opportunityLineItems);
for(OpportunityLineItem opportunityLineItem:opportunityLineItems){
System.debug('opportunityLineItem------------------'+opportunityLineItem);
System.debug('PricebookEntryId------------------'+opportunityLineItem.PricebookEntryId);
System.debug('PricebookEntry Name------------------'+opportunityLineItem.PricebookEntry.Name);

}
Visual Force 

<apex:pageBlockTable value="{!OpportunityLineItems}" var="item" headerClass="headerRow" rowClasses="odd even">
<apex:column value="{!item.PricebookEntry.Name}" headerClass="headerRow" headerValue="Deal Products" />
<apex:column value="{!item.PricebookEntry.ProductCode}" headerClass="headerRow" headerValue="Part Number" />
<apex:column headerClass="headerRow" headerValue="QTY" value="{!item.Quantity}"/>
<apex:column headerClass="headerRow" headerValue="MSRP" value="{!item.ListPrice}" />
</apex:pageBlockTable>

Alexander_EAlexander_E

Hello Kalluru,

 

here is a untested version of your request:

 

1. write a wrapper class:

 

public with sharing class OpportunityLineItemWrapper {
	
	public OpportunityLineItem oppItem {get; set;}
	public PricebookEntry pbeName {get; set;}

   public OpportunityLineItemWrapper() {
      pbeName = new PricebookEntry();
      oppItem = new OpportunityLineItem();
   }
}

 

2. write this in your extensionclass:

 

		public List<OpportunityLineItemWrapper> oliwrapper {get; set;}

            OppProds = [SELECT ServiceDate, PricebookEntryId,  OpportunityId FROM OpportunityLineItem WHERE OpportunityId = :ApexPages.currentPage().getParameters().get('Id')];

            oliwrapper = new List<OpportunityLineItemWrapper> ();


            for ( OpportunityLineItem oneoli : OppProds){
                OpportunityLineItemWrapper oliw2 = new OpportunityLineItemWrapper();
                oliw2.oppItem = oneoli;
                oliw2.pbeName = [Select Id, Name From PricebookEntry WHERE Id = :oneoli.PricebookEntryId LIMIT 1];
               
                oliwrapper.add(oliw2);
            }


 3. put this table in your VF Page:

 

		<apex:pageBlock >
			<apex:pageBlockTable var="oli" value="{!oliwrapper}" >
 				<apex:column value="{!oli.oppItem.ServiceDate}"/>
 				<apex:column value="{!oli.pbename.Name}"/>
 			</apex:pageBlockTable>
		</apex:pageBlock>

 

 

I hope, this helps..

 

best regards

 

Alexander