I'm working on a managed package that inserts certain standard objects on package install via the post install handler (accounts, contacts, etc), and my goal is that these objects will be deleted if the user decides at some point to uninstall the package.

This is simple enough to accomplish via the post uninstall handler. However, to post this package on the exchange SFDC requires through their security check that CRUD and FLS is manually enforced, which means I am required to essentially add the below if statement, as an example:

if (Account.sObjectType.getDescribe().isDeletable())
    delete accounts;

BUT, apparently the special user that creates and deletes the data (which is simply given the name of the package) apparently doesn't have delete access, as evidenced by the fact that adding this if statement prevents the delete from occurring on uninstall (alternatively, adding the keywords 'with sharing' to the class header likewise produces this same result). Apparently this special user does however have create access, as evidenced by the initial inserts going through after having performed the isCreateable() check in the install handler. It seems difficult to find any information on what kind of access this special user has and why.

Can anyone help shed light on why this is happening and how I might overcome it?

  • by objects, do you mean records?
    – Nick C
    Oct 16, 2016 at 1:43
  • I don't believe that the community will be able to answer this. Have you tried asking the Security Review Team for some advice on how to proceed? Ideally, you could add an answer here, and I'm sure we'd be grateful for the knowledge.
    – sfdcfox
    Oct 16, 2016 at 2:42
  • Were you ever able to delete records ? I tested with class having without sharing and delete operation still does not happen . Oct 16, 2016 at 3:35
  • sdfcfox, I just submitted a case to Salesforce via the partners portal. However, having had cases like this dismissed in the past as being outside of scope because of custom dev, I'm wondering if you have a different suggestion as to how I might inquire with the security review team? Thanks for your reply, you are becoming a friend of mine on these forums :) Oct 21, 2016 at 1:56

2 Answers 2


Do not install the package in your PROD and I hold no responsibility in deleting your data

The uninstall scripts cannot do a delete operation and the special user will not have writes to delete due to security reasons.

Even though your code compiles ,you will see during uninstall the lines with DML delete are not executed .

Here is an managed package i created to test this


It has a simple code like below

global without sharing class UninstallScript implements UninstallHandler {
global void onUninstall (UninstallContext context) {
    /* these appear to do nothing during the uninstall */
    delete [SELECT Id FROM Contact ];
    delete [SELECT Id FROM Account];

Try installing and then uninstalling ,the package has an uninstall handler which does a delete operation but you will notice in logs no statements will be executed .I guess this is a security measure from salesforce (Although I could not find official docs on this) to not allow deletion of records in the uninstall script.

Generally uninstall scripts are to send a survey link via email to ask feedback on what went wrong that customer had to uninstall the package .


I took sfdcfox's advice and spoke with the Salesforce security team about this issue. They were very understanding and made an exception for our security review, given that this issue could not be resolved in the app package itself.

It seems indeed that the special app install/uninstall user does in fact have limited permissions. Unfortunately I was not given any specifics on this topic.

You must log in to answer this question.

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