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?

5
  • What object are you trying to delete from? Is it a standard object or a custom object from the managed package? Commented Feb 13, 2018 at 16:22
  • It's a custom object but not from the package being uninstalled.
    – Ben
    Commented Feb 13, 2018 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
    Commented Feb 13, 2018 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
    Commented Feb 13, 2018 at 16:54
  • Apologies, I misread that it's upon uninstall. I'd still consider it worrying functionality.
    – David Reed
    Commented Feb 13, 2018 at 17:33

1 Answer 1

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.

You must log in to answer this question.

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