-1
list<Opportunity> opportunity=[select Type, TotalOpportunityQuantity, TM_Quote_ID__c, StageName, SKI_Number__c, Probability, Name,KIS_Number__c, HasOpportunityLineItem, ForecastCategoryName, ForecastCategory, Amount,AccountId, Opportunity_Number__c, (Select Id, PricebookEntryId, Product2Id, ProductCode, Name, Quantity, Discount,TotalPrice, UnitPrice, ListPrice, ServiceDate, Description, Recurring_Charge__c, TM_Forecast_Type__c, 
Product_Account__c, Product_Account_Description__c From OpportunityLineItems) from Opportunity where opportunity_number__c=:lOpportunity[0].opportunity_number__c];

system.assertequals(opportunity[0].opportunitylineitems__r.quantity,tmquote.productList[0].quantity);    

this assertequals says that invalid foreign key relationship so how do i access fields from opportunitylineitem from the subquery of the list??

0

It returns a list, change it to:

system.assertequals(opportunity[0].opportunitylineitems[0].quantity,tmquote.productList[0].quantity);

When you access child records it return List of Child Sobjects.And standard sobject/fields doesn't require __r

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.