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
Jerry Xu 1Jerry Xu 1 

why my query doesn't return detail fields for my child custom object?

Hi,
We added a custom object called Analytics Group under Account.  It is a list and I created one object manually under one account

When I run this query:
"SELECT id, name, Sage_ID__c,FCA_Number__c, Owner.Name,(SELECT Group_ID__c,Account_Limit__c,Concurrent_Limit__c,Display_Name__c,Expiry_Date__c,Notes__c,Version_Name__c,Version_ID__c FROM Analytics_Groups__r) FROM Account where id=xxxx"

I can see that the account does have one Analytics_Groups__r returned. But it is returned as a QueryResult, with two Fields "FieldsToNull" and "ID", and both fields are null. I asked those fields: Group_ID__c,Account_Limit__c,Concurrent_Limit__c,Display_Name__c,Expiry_Date__c,Notes__c,Version_Name__c,Version_ID__c
but none of them seem to be returned (or maybe I just don't know where to retrieve them)?

Can someone help?
Jerry Xu 1Jerry Xu 1
Did some investigation, the result was received correctly but when it does  JsonConvert.DeserializeObject<T>(jObject.ToString()), the Analytics_Groups information is lost for some reason
BDatlaBDatla
BDatla
Hi ,

Suppose you are using a list to store the query result blow code will be useful for you to get values.

List<Account>  accList = new List<Account>(["SELECT id, name, Sage_ID__c,FCA_Number__c, Owner.Name,(SELECT Group_ID__c,Account_Limit__c,Concurrent_Limit__c,Display_Name__c,Expiry_Date__c,Notes__c,Version_Name__c,Version_ID__c FROM Analytics_Groups__r) FROM Account where id=xxxx"]);

Set<string> groupIds = new set<string>();
for(Account acc : accList){
    for(Analytics_Groups__c ag: acc.Analytics_Groups__r){
           groupIds.add(Group_ID__c);
    }
}

You can change the code within the for loop as you required.


Regards,
BDatla
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Jerry Xu 1:


 Looks like you were using partner wsdl, can i know from which platform were you trying to consume partner wsdl??
 In case of java, below link might help you.,

https://help.salesforce.com/apex/HTViewSolution?id=000005452&language=en_US


Thanks,
Balaji C Garapati
Jerry Xu 1Jerry Xu 1
I am using the enterprise wsdl. Turned out I have to do this to get custom object's detail populated:

under the Account class in the wsdl, it was:
public QueryResult Analytics_Groups__r
        {
            get {
                return this.analytics_Groups__rField;
            }
            set {
                this.analytics_Groups__rField = value;
                this.RaisePropertyChanged("Analytics_Groups__r");
            }
        }
        

I need to manually modifiy it to:
public QueryResult<Analytics_Group__c> Analytics_Groups__r
        {
            get {
                return this.analytics_Groups__rField;
            }
            set {
                this.analytics_Groups__rField = value;
                this.RaisePropertyChanged("Analytics_Groups__r");
            }
        }

Then the searilization works as expected.