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
PBS_IC786PBS_IC786 

Queryresult structure for Flex/Apex

Assuming the structure for a queryresult is different in Flex (not sure if it is?), how can I get to the values stored within the objects which the queryresult brings back.

Specifically, I have a query which is bringing back 3 columns and 1 record.  2 out of the 3 columns are actually relationship objects with multiple records contained within them.  I need to get the values in the fields of these relationship objects in order to do processing with them...

This pseudo format is returning blank when I can see the data in the apex explorer-

queryresult.records[0].relationshipobject[0].customfieldname

Any help is greatly appreciated...
testortestor
are you using a nested query?
PBS_IC786PBS_IC786
yes I guess you can call it that
SuperfellSuperfell
If you have an aggregate child query (e.g. select name, (select firstname from contacts) from account) then, the contacts object in the outer queryResult is another queryResult, rather than a directl array of contacts, so, you'd need something like
queryresult.records[0].contacts.records[0].firstname
PBS_IC786PBS_IC786
Thank you Simon...that did it.  You guys are all OK!
mschmidtmschmidt
Okay, but what if it's a child-to-parent relationships using a Notation like:

Code:
SELECT Type, Name, Folder.Name, Folder.CreatedDate FROM Document

How can I access the fields Folder.Name, Folder.CreatedDate? Something like:
    queryresult.records[0].folder.records[0].name   or   queryresult.records[0].folder.name
doesn't work!

Actually I'm working with the Force.com IDE for Eclipse and tried this query with the Schema Browser and it groups Folder.Name and Folder.CreateDate in a "Lookup to Folder"-View. But I don't know what that means for the way how I can access it.

Thanks,
mschmidt