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
jarthurjarthur 

custom object relationship query

Is it possible to use the CreatedById reference to return a user's name from the User table when writing a select statement for a custom object?  I see documentation for dotted notation in traversing standard objects and using the __r suffix and dotted notation for custom objects but I'm not finding a solution for custom object to standard object relationships.

Thanks.
SuperfellSuperfell
selected name, createdBy.Name from foo__c


the describeSObject call surfaces all this info, you might want to try one of the schema/soql tools, they make working this stuff out easy.
jarthurjarthur
Thanks but that did not work. I'm using my enterprise wsdl as a web reference. When I create a instance of my custom object (myVisits) 'Name' is not available as far as Microsoft Visual Studio is concerned and CreatedById is not a valid part of the path to 'Name'. If I fetch just the CreatedById everything works but my users are not impressed with a list of reference keys. Code snippet: 'Start CRM Partners Info here qr = sfdc.query("select Business_Visit_Comments__c, CreatedById.Name," _ & "Business_Visit_Date__c," _ & "Partner__c" _ & " from CRM_Partners_Information__c where Account_ID__c = '" & lookFor & "' order by Business_Visit_Date__c") sfdc.QueryOptionsValue = New sforce.QueryOptions() If (qr.size > 0) Then Label3.Visible = True Visits.Text = "" For i As Integer = 0 To qr.records.GetUpperBound(0) Dim myVisits As sforce.CRM_Partners_Information__c = CType(qr.records(i), sforce.CRM_Partners_Information__c) Visits.Text += "
" & myVisits.Partner__c & "
" _ & "
" & myVisits.Business_Visit_Comments__c & "
" _ & "
" & myVisits.CreatedById.Name & "
" _ & "
" & myVisits.Business_Visit_Date__c.ToString & "
" Next
SuperfellSuperfell
I didn't say createdByid.name, i said createdBy.Name.

Again i'd highly recommend you try one of the schema/soql developer tools (AppexExplorer, SoqlX, Developers sidekick).
jarthurjarthur
Thanks.  Everything works.  Picked up Apex Explorer along the way.