I need some help with migration of some leads and its related tasks from one prod org to another.

I have a list of 40k leads which need to be moved over and with it all the tasks related to these leads.

I do have the csv of these 40k leads, but how do i get a csv of tasks related to these 40k leads only?

I am using Apex Data loader.

  • Is it possible to select these 40k leads in Salesforce still? I mean are these records marked in any way so you might be able to query them in Data loader?
    – user28311
    Commented Jan 26, 2019 at 21:04
  • Yes, they can. They can be queried
    – Prady
    Commented Jan 27, 2019 at 4:18
  • You might want to try a third party product that allows nested queries
    – user28311
    Commented Jan 27, 2019 at 8:07

2 Answers 2


As you can't do much with Apex Dataloader in terms of queries, a two step approach might help:

  1. Use Batch Apex to update an unused Task field related to the 40k leads to mark all these tasks for export
  2. Use Dataloader to export the tasks with the particular field marked for export
  • Thanks Fred, We could use subqueries on your data loader . I have added an answer with an example of the query
    – Prady
    Commented Jan 27, 2019 at 14:19

You could do what @Fred said but a much simpler way is to use subqueries in apex dataloader.

SELECT id,subject from task where whoid in(SELECT id from Lead where status__c = 'Active')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .