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
SANTOSH R 11SANTOSH R 11 

How to delete records after successful insertion?

I'm writing an apex batch class to migrate data from one object to another. How to delete only the records of old object which are successfully inserted into the new object?
@GM@GM
Hi SANTOSH,

​Create an external field on new object to put the old object SFDC id and do copy all data from old object to new object.

Finally you can query the records to deleted from old obejct from using external field of new object which are inserted successfully. 
So that you will be in safe place to trace which records are inserted and deleted.

Regards,
GM
SANTOSH R 11SANTOSH R 11
Thanks GM