How Does an Uninstall Script Work?
An uninstall script is an Apex class that implements the UninstallHandler interface. This interface has a single method called onUninstall that specifies the actions to be performed on
uninstall.
1global interface UninstallHandler {
2 void onUninstall(UninstallContext context)
3}
The onUninstall method takes a context object as its argument, which provides the
following information.
- The org ID of the organization in which the uninstall takes place.
- The user ID of the user who initiated the uninstall.
The context argument is an object whose type is the
UninstallContext interface. This interface is
automatically implemented by the system. The following definition of the UninstallContext interface shows the methods you can call on
the context
argument.
1global interface UninstallContext {
2 ID organizationId();
3 ID uninstallerId();
4}