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
Nick ValerioteNick Valeriote 

Workbench Query for Multiple Related Objects

Hi SF Community!

I'm looking to create a SOSL or SOQL query in Workbench based on the following:

- I have 3 custom objects that are related - Projects (parent), Tasks (child to projects), and timesheets (child to projects and tasks).
- I want to create a query that pulls all of the above records based on a project created date less than June 30, 2013, and a task created date or timesheet created date greater than June 30, 2013.

I'm not a developer, but have managed to create some very basic SOQL queries in workbench.  Not sure how to do this one though.  I'm using Workbench so I can export the results.

Thanks!
Nick
Best Answer chosen by Nick Valeriote
Alain CabonAlain Cabon
Hi,

If you are not a developer, the best option is to create a report (very limited for the the result on screen) and export the results ("unlimited" number of rows) but there is also a solution with a SOQL query even if the query timeout is a big constraint.

The most easy way for this SOQL query is to start with the "last" child (here the timesheets) and you get all the parent values using the relationships (a cross-object SOQL query ("upwards"))

For a custom object: the relationship name is <object name>__r and you chain these relationships "upwards" the parents.

SELECT  CreatedDate,  task__r.CreatedDate , task__r.field1__c, task__r.project__r.field2__c, task__r.project__r.CreatedDate
FROM  timesheet__c
WHERE CreatedDate > 2013-06-30T00:00:00-00:00

The workbench doesn't work well when you want to export the result of a cross-object SOQL query in csv (forbidden by the tool or empty columns as results) I never use the workbench for these cross-object SOQL queries.

I use the dataloader (this tool can export data  with cross-object  SOQL queries (not in bulk mode))

The dataloader is the official tool of Salesforce. The workbench is not a supported tool by Salesforce.

User-added image

 

All Answers

Alain CabonAlain Cabon
Hi,

If you are not a developer, the best option is to create a report (very limited for the the result on screen) and export the results ("unlimited" number of rows) but there is also a solution with a SOQL query even if the query timeout is a big constraint.

The most easy way for this SOQL query is to start with the "last" child (here the timesheets) and you get all the parent values using the relationships (a cross-object SOQL query ("upwards"))

For a custom object: the relationship name is <object name>__r and you chain these relationships "upwards" the parents.

SELECT  CreatedDate,  task__r.CreatedDate , task__r.field1__c, task__r.project__r.field2__c, task__r.project__r.CreatedDate
FROM  timesheet__c
WHERE CreatedDate > 2013-06-30T00:00:00-00:00

The workbench doesn't work well when you want to export the result of a cross-object SOQL query in csv (forbidden by the tool or empty columns as results) I never use the workbench for these cross-object SOQL queries.

I use the dataloader (this tool can export data  with cross-object  SOQL queries (not in bulk mode))

The dataloader is the official tool of Salesforce. The workbench is not a supported tool by Salesforce.

User-added image

 
This was selected as the best answer
Nick ValerioteNick Valeriote
Thanks, Alain.  This is helpful!.  Nice little tutorial, and example, regarding SOQL queries.  Cheers.
vicky kumar 24vicky kumar 24
thanks for sharing, I appereciate your work (https://www.worldexpress.xyz/)
Richard Daly 3Richard Daly 3
Nesting is not available in workbench, fyi
Free jobfindFree jobfind
FREE JOBS FIND (https://FREEJOBSFIND.COM)
Free jobfindFree jobfind
Free jobfindFree jobfind
Free jobfindFree jobfind
Free jobfindFree jobfind
Free jobfindFree jobfind
Shadi Anudan Online Form Vivah Anudan 2021 (https://freejobsfind.com/shadi-anudan-online-form/)
Free jobfindFree jobfind
Free jobfindFree jobfind
Uttar Pradesh Ration Card (https://freejobsfind.com/up-ration-card/)
Free jobfindFree jobfind
Khata Khesra (https://khatakhesra.in)
Free jobfindFree jobfind
Aapda Vibhag Sampoorti Portal Login (https://freejobsfind.com/aapda-bih-nic-in/)
 Bihar Aapda Rahat Kosh | Badh Raahat Bihar Online | 6000 Badh Rahat List | बिहार फसल छती-पूर्ति | किसान राहत 6000 रुपय सूचि @aapda bih nic in
Free jobfindFree jobfind
Free jobfindFree jobfind
PM kisan Status (https://ncvtresult.com/pm-kisan-status/) What is Prime Minister Kisan Samman Nidhi Yojana

This is a scheme run by the central government in the interest of farmers, under this scheme ₹ 6000 is deposited directly into the bank account in three installments per year.

How to register in PM Kisan Yojana

You can register in PM Kisan Yojana by visiting the website of the official of Agriculture Department or the official website of PM Kisan of the Central Government.

Where to check PM Kisan Status

 The farmer who is already registered and is taking benefit of PM Kisan can visit the official website of PM Kisan and click on Beneficiary Status to check all the installations of PM Kisan

What are the important papers in PM Kisan

 Important documents in PM Kisan are Aadhar card and land document
Rahul Chand 2Rahul Chand 2
NCVT Mis Portal (https://ncvtmisportal.in) National Council for Vocational Training Free Online Learning Portal For ITI Students.In This portal you can find ITI Books (https://ncvtmisportal.in/iti-book) ,
NIMI Question Bank (https://ncvtmisportal.in/nimi-question-bank-pdf-download/) , ITI Syllabus (https://ncvtmisportal.in/iti-syllabus-download/) , ITI Result (https://ncvtmisportal.in/ncvt-iti-result/) , NIMI Mock Test (https://ncvtmisportal.in/iti-nimi-mock-test-all-trades/) .