• Luis Murillo
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi Salesforce Community,


I got an error list apex with a SoQL script using multiple sObjects: Opportunity & OpportunityLineItems.
Script:

-------------------------

SELECT Amount, Name, ( SELECT Quantity, ListPrice,PriceBookEntry.ProductCode, PriceBookEntry.UnitPrice,TotalPrice, PricebookEntry.Name,PricebookEntry.product2.Family FROM OpportunityLineItems ) FROM Opportunity where id ='006i00000026VOj'

--------------------------
It is all the data that I need to show into a table visualforce page. But the list apex class, has an error. : Illegal assignment from LIST<Opportunity> to LIST<OpportunityLineItem>


I think this happens because maybe I need 2 lists to each sObjects. Actually I am using just 1 list with all my script SoQL.

Apex:

-----------------

public class clsPaginaPedidos {

    public Opportunity opp {get;set;}    

   List<OpportunityLineItem> OpportunityLineItem;  //List        

 

public List<OpportunityLineItem> getOpportunityLineItem() { 

 if(OpportunityLineItem == null) OpportunityLineItem = [SELECT Amount, Name,

(SELECT Quantity, ListPrice,PriceBookEntry.ProductCode, PriceBookEntry.UnitPrice,TotalPrice, PricebookEntry.Name, PricebookEntry.product2.Family FROM OpportunityLineItems)

FROM Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];
   

return OpportunityLineItem;         

    }//End List  

 

}//End class

-----------------


Any help??

Thanks,

   Luis.