Skip to main content
 I am trying to extract data from SF via the API. I wish to actually recreate a report I have already made in SF, by extracting the raw data for use in another application. I can connect to salesforce and download many of the fields I need no problem. However, I have an instance of a Opportunity Owner field which (I think) which is of a LookUp(USER) datatype. How can I access the result of that lookup via the API? I am thinking it would have to be along the lines of a SQL join statement, but I understand Salesforce SOQL doesn't have a join statement? How does one overcome this? Thanks in advance
7 件の回答
  1. 2011年8月17日 16:11
    A best practice here would be to download the Force.com IDE if you don't already have it, and connect it to your Salesforce.com org.  When you do so, you'll see a little, nondescript icon called "salesforce.schema" at the top level.  Double click it and you'll find a query builder that can be very helpful in writing queries like this.

     

    In your case, you have written a subquery instead of a relationship query.  You write relationship queries when you're looking up (like from opportunity to its parent User), and you write subqueries when you're looking down (like from opportunity to its child opportunity products).  So the good news is that the query you need is simpler than you think, just

     

    Select o.Owner.Alias, o.OwnerId, o.FiscalYear, o.CloseDate From Opportunity o
0/9000