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
Sarvesh  SharmaSarvesh Sharma 

parsing QueryResult records

i am trying to extract out the field names from the QueryResult object returned by executing partnerCOnnection.query(). I know it returns an array of SObjects. 
 Now if i enter a query as followed:-

SELECT Contact.LastName ,Contact.FirstName ,Contact.Account.BillingStreet ,Contact.Account.BillingCity ,Contact.Account.BillingState ,Contact.Account.CreatedBy.Country ,Contact.Account.CreatedBy.Latitude ,Contact.Account.CreatedBy.Longitude ,Contact.Account.CreatedBy.Email FROM Contact LIMIT 1


  The sObjects[] returned is:-


[XmlObject{name={urn:partner.soap.sforce.com}records, value=null, children=[XmlObject{name={urn:sobject.partner.soap.sforce.com}type, value=Contact, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Id, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}LastName, value=YKJ01-0004, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}FirstName, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Account, value=null, children=[]}]}]
 
i.e. it just returns the filed values of Contact object. it does not give any information about the other related objects(Account and User) .

but now if i remove the LIMIT 1 it returns a sobject[] as follows:-

[XmlObject{name={urn:partner.soap.sforce.com}records, value=null, children=[XmlObject{name={urn:sobject.partner.soap.sforce.com}type, value=Contact, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Id, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}LastName, value=Gonzalez, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}FirstName, value=Rose, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Account, value=null, children=[XmlObject{name={urn:sobject.partner.soap.sforce.com}type, value=Account, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Id, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}BillingStreet, value=312 Constitution Place
Austin, TX 78767
USA, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}BillingCity, value=Austin, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}BillingState, value=TX, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}CreatedBy, value=null, children=[XmlObject{name={urn:sobject.partner.soap.sforce.com}type, value=User, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Id, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Country, value=IN, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Latitude, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Longitude, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Email, value=sasharma@informatica.com, children=[]}]}]}]}, XmlObject{name={urn:partner.soap.sforce.com}records, value=null, children=[XmlObject{name={urn:sobject.partner.soap.sforce.com}type, value=Contact, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Id, value=null, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}LastName, value=Forbes, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}FirstName, value=Sean, children=[]}, XmlObject{name={urn:sobject.partner.soap.sforce.com}Account, value=null, 

basically it contains all the information of all the objects fields.

SO i want to understand how is the sObject array is formed . can anyone explain it with an example(preferrably with relationship in the query)

thanks in advance!!!!!!!!!
ShashankShashank (Salesforce Developers) 
Does that single record have related records at all? The reason could be that the record does not have any related account record.