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
KaydanceKaydance 

soql mass data dump

I am running into an issue with the soql queries. I am fairly new to using the soql and am not completely familiar with the restrictions. I am trying to pull information on the Cases in my sfdc, my question is regarding the relationship w/ the case owner information. I am using the Ajax Tookit/ Explorer to format my query, when I expand the information in Cases -> Parents -> Owner I only have access to:
Id, Name, Type, Email, DoesSendEmailToMembers, CreatedDate, LastModifiedDate, SystemModstamp.
The information I need is: UserRole.Name. Can someone explain to me how I go about tying these object together in order to obtain the information I need? I couldn't find really anything regarding joins like I would do in sql e.g.
SELECT a.CaseNumber, a.Status, a.CreatedDate, b.UserRole.Name
FROM Case a
JOIN User b
ON a.Owner.Id = b.Id


My end goal is to pull a query of almost all of the information tied to the cases so I can load this info into my database....If the above is not possible is there a better way to automate data dumps? I currently have a report in sfdc that gives me all of the info I need, however I need to automate this process so I don't have to manually download the report and insert it.


Thanks for any assistance.
RickyGRickyG
Kaydance -

SOQL ain't SQL, as I always say.  You cannot do joins in SOQL, but must use relationship fields to establish the relationship, and dot notation to traverse the (upward relationship).

The query you are looking for is something like this -

Select c.Owner.Name, c.CaseNumber . . . . From Case c

You can see the use of dot notation to the Owner object.  I recommend to you both the Apex documentation and Chapter 12 of the new Developer's Guide, which you can get through this page.

You will also probably get some good use out of the Salesforce Schema Explorer, which is a part of the Force.com IDE.  This tool gives you the ability to interactively build SOQL queries by selecting columns names.

Hope this helps.