[SalesForce] query user and profile

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.

Best Answer

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 
      xsi:type=\"sf:sObject\"   
      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" 
      xmlns:sf=\"urn:sobject.partner.soap.sforce.com\">
          <sf:type>Profile</sf:type>
          <sf:Id xsi:nil=\"true\" />
          <sf:Name>Custom: Admin</sf:Name>
    </sf:Profile>"
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.

Related Topic