We need to replace a field in our managed ISV package with another field. For our software still to work after this change we plan to add a Batch that copies the old field value to the new one. We want to start this batch using an install script which will be automatically started on upgrades.

Is that a feasible solution or could such a long running operation interfere or corrupt other installation things?

I think this question is especially relevant regarding the new feature to remove fields that is coming in the next release.


The code runs asynchronously, after all other effects of the installation have been applied. Notably, this means that your batch script won't be able to query the deleted field, because it would have already been deleted by the time your batch script starts. The only safe way to ensure that the deletion of the field won't hose things up is to not delete the field until you have run an upgrade for all customers that has an install handler that can perform the data migration (in other words, both the old field and new must simultaneously exist).

From a practical standpoint, this means you should consider any version after the deletion of fields to be a major upgrade (e.g. if the last version in a set is 2.35, then you delete a bunch of fields, the next version should be 3.0). Doing this will let you safely upgrade customers, because you can remember that the last minor version (e.g. 2.35) must be installed for clients using 2.x before 3.0, or the data migration will fail, and your data may be left in an inconsistent state. There is a reason why salesforce.com hasn't allowed this in the past, because the migration path can be messy.

As a final note, you could also skip that part and simply remember to perform a data backup beforehand, perform the upgrade, then perform a data load afterwards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.