[SalesForce] How to do Data Migration in salesforce

What are the ways to do Data Migration in Production Organization. I am trying to do something like

  1. Migrate data from Account lookup field in Lead to new lookup field in the same object (lookup for a custom object)
  2. Move data from one object's fields to another custom object.
  3. Change all null values of a field to 'Default'

How to achieve this in salesforce. I know SOQL queries can only be used for selecting records and not for inserting/updating. I find using Apex Data Loader as a good solution. I tried exporting data from the object, modified values, created new csv to support new objects and copied data and imported back into salesforce. Is this the right way of doing it?Please suggest me a solution. I am new to salesforce!.

Best Answer

In my opinion, it is better to achieve the migration using the Data Loader, when you can, than it is to write Apex, but as with everything it depends on the specific scenario.

Benefits of using the Data Loader:

  • You don't have to worry about coding errors when you use the Data Loader.
  • You don't have to worry about limits as much. For example, if you are migrating a sizeable number of records you'll quickly run into limits with the number of records returned by your SOQL query.

That being said, there are some times when Apex might be the way to go.

  • You have complex business logic that isn't as simple as exporting one Object's fields and importing to another. In this case, I'd recommend creating a Batch Apex job, unit testing it, and testing it in a sandbox prior to production.
  • You have an Object that has a few (e.g., 10) records and you are copying a value from one field to another field. Anonymous Apex would be reasonable to me. With this small data set, it's simple, easily verifiable, and you likely won't hit limits.
Related Topic