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
geis6geis6 

Help with SOQL code please

I'm trying to perform a data dump of Case data for further crunchin in Excel, my users have no use for "OwnerId" and would prefer the actual name of the primary owner.  I thought I could do this witha relationship query, but I can't seem to get it to work.  Salesforce Support tells me that getting the Name of the Primary owner while Querying the Case object is not possible, I'm not sure I belive the first line support rep that told me this.

Does anyone have any experience doing something like this?  Can someone help me out with my code?  I see in Apex Explorer that Case is a child of the user object.

Select Id, CaseNumber, CreatedDate, Account.Name, Account.Industry, Contact.Name, Product__c, Component__c, Sub_Component__c, Status, OwnerId, Request_Type__c, Incident_Priority__c, Version__c, Origin, Root_Cause__c, ESC_Status__c, Integration_Type__c, Zone_Type__c, Actual_First_Response__c, ClosedDate, TT_Number__c, Subject FROM Case WHERE RecordTypeId = '012700000009NR5'

Cheers,

Ward


SuperfellSuperfell
select id, caseNumber, owner.name from case
geis6geis6
Thanks Simon,  But owner.name shows up null for every case record that I have.  Any other ideas?

Cheers,
Ward
SuperfellSuperfell
what tool are you running the query with ?
geis6geis6
Data Loader 12.0
geis6geis6
Anyone else have any ideas on how to get this done?
 
Cheers,
Ward
SuperfellSuperfell
Looks like the data-loader doesn't support SOQL-R, the query is fine, you just need to find a tool that can generate a CSV from the output. (or write your own)
geis6geis6

Thanks for the info Simon.

Anyone know of any way to run a query as a scheduled task for CSV output besides running data-loader at the command line?

Cheers,

Ward 

TCAdminTCAdmin
Hello geis6,

I just tested in Data Loader 12 and the following query should get you the results you are looking for.

SELECT CaseNumber, Owner.Name FROM Case

Note that the Data Loader is case sensitive and owner.name and Owner.Name will return different results.
geis6geis6
Thanks Chris!
 
It totaly works.  Great catch.
 
Cheers,
Ward
sfdcfoxsfdcfox
Wait... Isn't SOQL case insensitive for unquoted characters? So why does the Data Loader fail to pull this in correctly unless you capitalize Owner.Name? Does this work for other relationships as well? For example, I know that "select firstname,lastname,account.name from contact" doesn't work, but would "select firstname,lastname,Account.Name from contact" work? That's odd...