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
beener3beener3 

SOQL not working (multiple select)

Hi,

 

 I would like to run the following query (I've used APEX Data loader 18):

 

select c.BACS_Reference__c, (Select t.Worker_Bill_with_VAT__c From Timesheet__c t) From Contact c

 

 Notice that Contact is Master of Timesheet__c (in a Master-Detail Relationship).

 

 

This query is very similar to the following, which I have taken from the Apex Examples:  

 

SELECT Amount, Id, Name, (SELECT Quantity, ListPrice, PricebookEntry.UnitPrice, PricebookEntry.Name FROM OpportunityLineItems) FROM Opportunity

 This query works for me.

 

but with my query, I get an error:

 

Select t.Worker_Bill_with_VAT__c From Timesheet__c t ^Error at row:1:Column:68 (Arrow points under V of VAT)Didn't understand relationship 'timesheet__c' in From part of your Query call. if you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. please reference your WSDL or the describe call for the approriate names.

 offcourse the problem is not the '__r' (I did check). 

 

I think that the problem is finding the name of the child relationship (to Timesheet__c) from the Parent (Contact).

 

I have followed the suggestions of API Documentation to read through the WSDL file. I've looked at Enterprise WSDL (looking for that elusive type="tns:QueryResult").

I've also looked at the DescribeSObjects query, which was of little help:

 

(Using AJAX toolkit)var result = sforce.connection.describeSObject("Contact"); log(result.label + " : " + result.name + " : "); log("---------- child relationships ---------"); for (var i=0; i<result.childRelationships.length; i++) { var cr = result.childRelationships[i]; log(cr.field + " : " + cr.childSObject); }-------------------------------Answer: Executing code ...Contact : Contact : ---------- child relationships ---------ContactId : AccountContactRoleWhoId : ActivityHistoryContactId : AssetParentId : AttachmentBLND_Candidate__c : BLND_DFFF_Employment_Application__cBLND_Contact__c : BLND_DFFF_Sample_Survey__cBLND_Contact_Link__c : BLND_DFTE_Expense__cBLND_Contact_Link__c : BLND_DFTE_Time__cContactId : CampaignMemberContactId : CaseContactId : CaseContactRoleMemberId : CaseTeamMemberMemberId : CaseTeamTemplateMemberReportsToId : ContactContactId : ContactHistoryContactId : ContactShareItemId : ContactTagCustomerSignedId : ContractContactId : ContractContactRoleWhoId : EmailStatusWhoId : EventAttendeeId : EventAttendeeTemporal_Name__c : Inductions__cConvertedContactId : LeadParentId : NoteParentId : NoteAndAttachmentWhoId : OpenActivityContactId : OpportunityContactRoleContact__c : ProActiveContract__cTargetObjectId : ProcessInstanceTargetObjectId : ProcessInstanceHistoryTemporal__c : Reference__cContactId : SelfServiceUserSupervisor__c : SiteSupervisors__cManager__c : Site__cSecondary_Manager__c : Site__cStaff_Member__c : Staff_Team_Membership__cWhoId : TaskTimesheet_Supervisor__c : Team__cTimesheet_Supervisor__c : Timesheet_Snapshot__cWorker__c : Timesheet__cContactId : User------------------------------------------------------

 

 

 

Any ideas put forward would be much appreciated.

 

Thanks,

 

Ben 

 

 

Message Edited by beener3 on 03-09-2010 12:55 PM
SuperfellSuperfell
You need to use the correct relationship name, not the name of the object type (i.e. something else instead of timesheet__c). one of the schema explorer tools can help you find out what it is.
beener3beener3

Hi Simon,

 

I've tried finding out using the following tools:

 

  1. Force.com IDE Schema Explorer
  2. Ajax Toolkit
  3. WSDL Schema
I've strickly followed the guide, and also tried the plural name of my custom object.
Where do I go from here?
 
Thanks

 

Message Edited by beener3 on 03-09-2010 01:09 PM
SuperfellSuperfell
Its in the WSDL. look for the definition of your parent object, it'll include an element declaration for the child collection.
SuperfellSuperfell
Odd are its Timesheet__r or Timesheets__r
beener3beener3

I have tried that already. there is an object a child relationship "Timesheets__r" which is the plural name of Timesheet. You would think "Eureka, there it is" but no.

 

The Timesheets__r object for some reason points to the Snapshot of Timesheets. this is really annoying and I can't understand it.

 

Any help here would be much appreciated.