2

I'm writing a post-uninstall script for a managed package that will delete a set of records that are no longer used. This works fine at the moment but I want to make it capable of deleting very large numbers of records if necessary, higher than the limits imposed by Salesforce for a single transaction. Normally I'd write a batch class to handle a bulk delete like this but post-uninstall scripts don't allow this. Is there any way around this, or any other way of bulk deleting 100,000+ records from a post uninstall script?

  • What object are you trying to delete from? Is it a standard object or a custom object from the managed package? – salesforce-hacker Feb 13 '18 at 16:22
  • It's a custom object but not from the package being uninstalled. – Ben Feb 13 '18 at 16:27
  • Were I the database administrator, I would be very concerned about a managed package deleting 100,000 records from an object other than its own upon install. Why not build a Visualforce or Lightning page to allow the user to initiate the delete, using a batch class. – David Reed Feb 13 '18 at 16:42
  • That is our backup plan but I'd like it to be automated. To clarify, the records are deleted after UNinstall, not install, and were only created as a result of the package being installed in the first place. – Ben Feb 13 '18 at 16:54
  • Apologies, I misread that it's upon uninstall. I'd still consider it worrying functionality. – David Reed Feb 13 '18 at 17:33
0

Just schedule a batch to do the hard delete from within your post install script. Be aware though that this should have the without sharing keyword. Otherwise the post install script will fail.

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.