I'm fairly new to salesforce so please bare with me as my understanding of the API' and SOQL is very limited.

I'm having troubles linking user object and profile object through 1 query(), the correct information is returned if I run in developer console which also works when I try it in the linked server

basically profile.name is is not defined / empty when I run the query through query()

Developer Console: returns the correct profile name

select user.id, user.Email,user.FirstName,user.LastName,user.profile.name,user.Username,user.IsActive FROM user , user.profile

I have to run two queries in order to link the two together when I use salesForce.query("") method through the api.

any ideas what I can check into next?

Thank you for your assistance.

  • 4
    What language are you calling the API from? With the Partner API you usually have to traverse the nested XML elements in the Any property to follow references. May 7 '13 at 20:48
  • Hey @K-Sea, welcome to the site. When posting code fragments be sure to highlight the code and click the {} button to markt it as such.
    – Matt Lacey
    May 7 '13 at 23:55
  • Are you using the same user credentials to login in each case?
    – Matt Lacey
    May 7 '13 at 23:56

I ran your query via the Partner API.

select user.id, user.Email, user.FirstName, user.LastName, user.profile.name, user.Username, user.IsActive FROM user, user.profile

One small aside note about the query, you don't need the ", user.profile" in the from clause. SOQL will do the reference join for you without it.

The first sObject that came back in the query result had the following XmlElements in the Any property array:

0: "<sf:Id xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">005400000000001AAK</sf:Id>"
1: "<sf:Email xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">a.user@example.com</sf:Email>"
2: "<sf:FirstName xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">A</sf:FirstName>"
3: "<sf:LastName xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">User</sf:LastName>"
4: "<sf:Profile 
          <sf:Id xsi:nil=\"true\" />
          <sf:Name>Custom: Admin</sf:Name>
5: "<sf:Username xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">robert.doek@example.com</sf:Username>"
6: "<sf:IsActive xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">false</sf:IsActive>"

So to get to the Profile name element you will need to traverse via the Profile XmlElement. How you do that will depend on your language.

  • This is the first time I see a comma in a FROM. How does that work, is there an article where I can read more about it? I am talking about the FROM user, user.profile
    – Arthlete
    Apr 8 '19 at 17:48
  • 1
    @Arthlete That's an interesting question. So I, umm, made it one - Is there any use for defining additional entity types in a SOQL FROM clause?. Apr 9 '19 at 1:13
  • what are the use cases for the partner API for @DanielBallinger May 23 '19 at 14:15
  • @Ohana The Partner API is great for SOAP operations to perform CRUD calls up to a few thousand records. It is dynamic, so it can handle changes to schema/metadata in the connected orgs. If you need more details see Using the Partner WSDL or search the existing questions here. May 23 '19 at 21:59
  • 1
    @Ohana It probably depends who you are talking to. Since the SOAP APIs predated the REST APIs I've always associated them first the the SOAP versions. So if you told me you were using the Metadata API I'd assume you were using the SOAP version. May 23 '19 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.