We have a bunch of picklist fields in our managed package. And some of those options are hardcoded inside Apex classes, e.g. if Status__c = 'Active' etc.

My concern is that after package installation subscriber could deactivate, delete or simply update picklist value breaking our apex logic inside managed package.

Is there any way to prevent this from happening? Making picklist restricted doesn't serve the purpose. Are there any best practices etc. how to protect your picklist options from subscriber?

  • I think it is not possible as stated in Salesforce documentation. Subscribers can rename or delete picklist field values. Keep this in mind when explicitly referencing a picklist field value in Apex. – Banshi Lal Dangi Feb 21 '18 at 5:19

For a regular picklist with values - all values can be changed by the subscriber org administrator, so it is not a good solution for you.

But if you base your picklist values on a Global Picklist Value Set, then it is not changeable by the org admin, and it is upgradable by the managed package.

According to this doc:

Picklist Values

  • Subscribers can rename or delete picklist field values. Keep this in mind when explicitly referencing a picklist field value in Apex.
  • Picklist field values can be added or deleted in the developer’s organization. Upon upgrade, no new values are installed. Any values deleted by the developer are still available in the subscriber’s organization until the subscriber deletes them.
  • Picklist field value sets, standard value sets, and global values sets can be added to developer and subscriber orgs. In the Spring ‘18 release and later, these value sets have the following behavior during a package upgrade:

    1. Label and API names for individual values don’t change in the subscriber orgs.
    2. New values aren’t added to the subscriber orgs.
    3. Active and Inactive value settings in the subscriber orgs don’t change.
    4. Default values in the subscriber orgs don’t change.
    5. Global value set label names change if the package upgrade includes a new label value.
| improve this answer | |
  • 1
    Subscriber still can edit/deactivate/remove options directly from global value set provided by the package. Restrictions apply only to picklist fields based on those global value sets, i.e. you cannot touch options inside such field, but you could still mess up with options by editing global value set itself. – wesaw Feb 24 '18 at 13:47
  • Also since global value set options are editable, I doubt it would allow us to upgrade options, cause as a rule of thumb in SF - "editable stuff is not upgradable" – wesaw Feb 24 '18 at 13:49

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.