I have a use case where I need to do a one-time data update for around 1.8 Million records. I know that we can achieve this with a data loader or we can create an Apex Batch to achieve this.

Challenge in Data Loader,

I have to update a field with other fields substring from the same object,

List<ObjectA> lstObject = [SELECT Id, Field1, Field2 FROM ObjectA];

List<ObjectA> lstObjectUpdate = new List<ObjectA>();
for(ObjectA ob : lstObject) {
    ob.Field1 = Id.ValueOf(ob.Field2.substring(0, 18));

if(lstObjectUpdate.size()>0) {
    update lstObjectUpdate;

I don't think we can achieve this in using Data Loader.

Challenge in Batch Apex

Actually we don't have any challenge, but we don't have to write a batch for one-time data update.

Is there any other way I can achieve this in the Production environment?

  • Why not just use a formula field (instead of the field you are trying to update)?
    – arut
    Commented Aug 8, 2020 at 14:38
  • No we can’t use it, because actually the field is the Master detail field. Commented Aug 8, 2020 at 16:13

1 Answer 1


This is easily achieved in Data Loader or any other ETL tool.

Extract the records, modify the data using Excel, LibreOffice, or your editor of choice, and reload it as an update. Ensure that you include the Id column to make this possible.

If the source field only contains a Salesforce Id, there's no need for the edit step. Just extract the data and perform an update, remapping the column for the old field to the desired new friend.

  • Yes, that's too easy with Excel to substring the value to make a new field value. Commented Aug 10, 2020 at 6:09

You must log in to answer this question.

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