You need to sign in to do that
Don't have an account?

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
Hi Simon,
I've tried finding out using the following tools:
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.