3

Context: I have a managed package and I removed a field from the latest version of the package. Now Although the field is not part of package the customer org still has the field and relevant data in it.

Requirement: Since the deprecated field contains sensitive data and has security risks, so I want to clean data from those fields.

What I tried:

  • Update Value for deprecated field from Post-install script, it didn't work (Error: Field API name is not valid)
  • Tried to query the field from anonymous Window in the developer console, it didn't work
  • Queried field from Query editor in developer console, It worked
  • Tried to create an Apex class in customer org with Version setting dependency of package set to an older version of the managed package and It worked

Is there a way to automate the clean data process for deprecated metadata from customer org?

Any best practice suggestion/opinion will also help

1 Answer 1

2

If I was doing this I would create two separate releases of the package:

  • The first:
    • Removes usages of the field from the package.
    • Relabels the field as "Deprecated".
    • Includes a batch or queueable launched by the post install script to find records with values in the field and to update these records, setting the field to null.
  • The second:
    • Removes the field itself.

You then instruct customers to upgrade using both releases of the package.

Where you are now, you are stuck with having to provide guidance to the customers to either:

  1. Delete the field, in the hope this will clear the data, OR
  2. Write their own batch or queueable code (it must be outside your package) that does the clearing of this field. An alternative is to create an unlocked 2GP without a namespace that includes this batch/queueable code and instruct them to install this package and run the batch/queueable then uninstall the unlocked 2GP again afterwards.

You must log in to answer this question.

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