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
pbattissonpbattisson 

Retrieving a related objects detail using the REST API

Hey

 

I am running thr following query through the REST API and it is returning (null) for the Account.Name field. The same query in SOQL Explorer shows evrry contact has an account linked to it which has a name.

 

 

"Select Name, LastName, Title, AccountId, Account.Name, Department, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, Phone, Fax, MobilePhone, Email from Contact Order By Account.Name, LastName"

 

 

Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

Account is not a required field, so you could well have some contacts with no accounts, and your query is not filtering those out. Otherwise, I seem to get the correct results,e.g.

 

 

 {
    "attributes" : {
      "type" : "Contact",
      "url" : "/services/data/v20.0/sobjects/Contact/0033000000fGI9CAAW"
    },
    "Name" : "Simon Fell",
    "Account" : {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v20.0/sobjects/Account/0013000000FO8lZAAT"
      },
      "Name" : "Salesforce.com"
    }

 

 

Can you include an example of your response, and perhaps some details on how you're accessing the related data ?

All Answers

SuperfellSuperfell

Account is not a required field, so you could well have some contacts with no accounts, and your query is not filtering those out. Otherwise, I seem to get the correct results,e.g.

 

 

 {
    "attributes" : {
      "type" : "Contact",
      "url" : "/services/data/v20.0/sobjects/Contact/0033000000fGI9CAAW"
    },
    "Name" : "Simon Fell",
    "Account" : {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v20.0/sobjects/Account/0013000000FO8lZAAT"
      },
      "Name" : "Salesforce.com"
    }

 

 

Can you include an example of your response, and perhaps some details on how you're accessing the related data ?

This was selected as the best answer
pbattissonpbattisson

Hey Simon

 

It was me being an idiot haha. All works now.

 

BTW, the toolkits and stuff are awesome. I canot express gratitude enough. I will buy you a beer if we ever cross paths - thats how good it is.

 

Paul