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
PrasadVRPrasadVR 

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) ; 

 

    

}

Jake GmerekJake Gmerek

What is the error message?

PrasadVRPrasadVR

Invalid foreign key relationship: Case.Requests__r.

Jake GmerekJake Gmerek

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.