You need to sign in to do that
Don't have an account?

Not able to display opportunitylineitem in opportunity controller
<apex:page standardcontroller="Opportunity" extensions="myOpptyController" tabStyle="Opportunity">
<apex:pageBlock title="opportunity product related list">
<apex:pageBlockTable value="{!opptyList}" var="div">
<apex:column >
<apex:pageBlockTable value="{!div.OpportunityLineItems}" var="custom">
<apex:column value="{!custom.Quantity}"/>
<apex:column value="{!custom.UnitPrice}"/>
<apex:column value="{!custom.TotalPrice}"/>
<apex:column value="{!custom.PricebookEntry.Name}"/>
<apex:column value="{!custom.PricebookEntry.Product2.Family}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Class is as follows:
public class myOpptyController {
public myOpptyController(ApexPages.StandardController controller) {
}
public List<Opportunity> opptyList{get;set;}
// public List<OpportunityListItems> opptyList1{get;set;}
public myOpptyController() {
opptyList = [SELECT Id,Name,
(SELECT ID, Quantity, UnitPrice, TotalPrice,PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems)
FROM Opportunity WHERE Id =: ApexPages.currentPage().getParameters().get('ID')];
// System.debug('opptyList ='+opptyList);
}
// public List<Opportunity> getopptyList() {
// return opptyList;
// }
}
This code is not displaying opportunitylineitem table
<apex:pageBlock title="opportunity product related list">
<apex:pageBlockTable value="{!opptyList}" var="div">
<apex:column >
<apex:pageBlockTable value="{!div.OpportunityLineItems}" var="custom">
<apex:column value="{!custom.Quantity}"/>
<apex:column value="{!custom.UnitPrice}"/>
<apex:column value="{!custom.TotalPrice}"/>
<apex:column value="{!custom.PricebookEntry.Name}"/>
<apex:column value="{!custom.PricebookEntry.Product2.Family}"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Class is as follows:
public class myOpptyController {
public myOpptyController(ApexPages.StandardController controller) {
}
public List<Opportunity> opptyList{get;set;}
// public List<OpportunityListItems> opptyList1{get;set;}
public myOpptyController() {
opptyList = [SELECT Id,Name,
(SELECT ID, Quantity, UnitPrice, TotalPrice,PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems)
FROM Opportunity WHERE Id =: ApexPages.currentPage().getParameters().get('ID')];
// System.debug('opptyList ='+opptyList);
}
// public List<Opportunity> getopptyList() {
// return opptyList;
// }
}
This code is not displaying opportunitylineitem table
Hi Femila Ice Cream,
If you want to show the opportunity line item on page please follow below instruction,
public class myOpptyController {
public List<OpportunityLineItem> oppLineItemList{get;set;}
public myOpptyController(ApexPages.StandardController controller) {
List<Opportunity> opptyList = [SELECT Id,Name,
(SELECT ID, Quantity, UnitPrice, TotalPrice,PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems)
FROM Opportunity WHERE Id =: ApexPages.currentPage().getParameters().get('ID')];
for(Opportunity opp :opptyList){
oppLineItemList = opp.OpportunityLineItems,
system.debug('@@oppLineItemList@@'+oppLineItemList);
}
}
}
<apex:page standardcontroller="Opportunity" extensions="myOpptyController" tabStyle="Opportunity">
<apex:pageBlock title="opportunity product related list">
<apex:pageBlockTable value="{!oppLineItemList}" var="div">
<apex:column value="{!div.Quantity}"/>
<apex:column value="{!div.UnitPrice}"/>
<apex:column value="{!div.TotalPrice}"/>
<apex:column value="{!div.PricebookEntry.Name}"/>
<apex:column value="{!div.PricebookEntry.Product2.Family}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Please try it and let me know.
If it will helpful.please mark it as a best answer.
Thanks,
Dileep
You have used apex class as an extension in your vf page so need to use parameterized constructor to initialize values.
Use below controller code.
Hello Femila Ice Cream,
Above mentioned 2 answers are correct. Please find my answer too.
Note : Create Opportunity Line Item to opportunity and provide id as shown in image.
Please select Best answer from above 3 answers. :)
Regards,
Jagadeesh