You need to sign in to do that
Don't have an account?
How to add subquery results to some other method?
Hi all,
I have an requriment where i need to add subquery fields to some other method
Here I am quering Case and requests details this two having Parent to child relation ship
Private static List<Case> Getcaselist () {
List<Case> caselist = [SELECT Id, (select Id, sale_order__C,Sales_request Number__C from Requests__r )
FROM Case limit 7];
return Caselist;
}
Now i need to add both case and requests details to this Method , but it doesn't understand relationship and it shows an error
Can anyone help me out
Private static List<string> getsome () {
List<String> returnList = new List<String>();
String currentRecord = '';
List<Case> caseList = GetCaseList() ;
for (Case c : caseList)
{
returnList.Add(DoubleQuoteString + c.Id+ '.txt' + DoubleQuoteString +
DoubleQuoteString + c.CaseNumber + DoubleQuoteString + FieldSeparatorString +
DoubleQuoteString + c.Requests__r.sales_order__C + DoubleQuoteString+
DoubleQuoteString + c.Requests__r.sales_requestNumber__C + DoubleQuoteString) ;
}
What is the error message?
Invalid foreign key relationship: Case.Requests__r.
Ok, what I would try is for now to un-abstract it. Take the SOQL query out of the first method and place it directly in the 2nd one. This way you will know if the data is getting lossed during the return or if something else id wrong.