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.

    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.

    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.

    Are you using the same user credentials to login in each case?

  • 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\">[email protected]</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\">[email protected]</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 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?.

    what are the use cases for the partner API for @DanielBallinger

    @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.

    Not to be pedantic, but is it commonly referred to as the the Partner API? I've always thought of (and referrred to it as) the SOAP API using the Partner WSDL. Thanks @DanielBallinger

    @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.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM

Tags used