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
AndySureDepositAndySureDeposit 

Query getRecords

The following line returns an error: 'basicSample_cs.apex.QueryResult' does not contain a definition for 'getRecords'

 

Account acct = (Account)qr.getRecords(i);

 

How can I use getRecords?

 

Thanks,
Andy

 

// below is actual code
qr = binding.query("SELECT Id, Name, (SELECT id,Account__c FROM ContactAccounts__r) FROM Account  WHERE CompanyId__c = " + strCompanyid);

if (qr.size > 0)
{
String[] ids = new String[qr.records.Length];
      for (int i = 0; i < ids.Length; i++)
      {
         ids[i] = qr.records[i].Id;
         Account acct = (Account)qr.getRecords(i); // does not compile!!!

      }
}

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
its qr.records[i], like the line above it.

All Answers

SuperfellSuperfell
its qr.records[i], like the line above it.
This was selected as the best answer
AndySureDepositAndySureDeposit

I was using an example at

 

www.salesforce.com/us/developer/docs/api/index_CSH.htm#sforce_api_calls_soql_relationships.htm

 

This example uses getRecords(). I am now doing what you suggested and everything works.

 

Thanks,
Andy