4

Recently we've run into a situation where we've provided an installation link for a patch version of the package (e.g. v1.23.4) to a user, and after this user has successfully installed the patch, the processes listed in the post-install script class appeared to not have run, so the user had to do the steps manually.

Does the post-install script run at all when the patch package is installed on an org? If it does, are there any special limitations for the post-install script when installing a patch version of the package?

Edit: Added sample code from the post-install script which doesn't seem to run:

global void onInstall(InstallContext context) {
    if (context.isUpgrade()) {
        this.removeCacheDocuments();
        // ...
    }
}

private void removeCacheDocuments() {
    List<Folder> folderList = [select id, name from Folder where name = 'Package Assets'];
    if (folderList.isEmpty()) {
        return;
    }

    Folder pkgAssetsFolder = folderList[0];
    List<Document> docList = [
        select id from Document
        where folderId = :pkgAssetsFolder.id
            and (
                name = :ConfigurationService.CACHE_DOCUMENT_A_NAME
                or name = :ConfigurationService.CACHE_DOCUMENT_B_NAME
            )
    ];
    if (!docList.isEmpty()) {
        delete docList;
    }
}
  • 1
    It will be better if we can see an excerpt of your post install script. It is possible that the way the code is written prevents the run from happening. – Sebastian Kessel Dec 15 '15 at 20:24
  • The context.isUpgrade() call seems a bit fishy to me here, maybe it returns false if the only thing to change is the patch version (major and minor version stay the same)? I couldn't find the documentation on InstallContext methods' behaviour... – Ivan Vrtarić Dec 16 '15 at 9:37
  • 1
    not sure but I think you need to use isPush() for this. :) – Ratan Paul Dec 16 '15 at 9:42

Your Answer

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

Browse other questions tagged or ask your own question.