7

It's so great that Salesforce.com allows to remove deprecated components from managed packages. We use that feature heavily to rework and improve our products.

But what I am worried about is all the deprecated stuff that still sits around in the customer org. All those fields, pages and static resources that should be better removed from all the existing customer orgs.

Besides documenting those artifacts and asking customers to remove them I I am looking for more automatic approach, e.g. a VF page that lists all those components.

Can this be done? Using the Tooling Api?

2
+25

This is possible.

ASAIK SFDC does not provide list of deprecated items in managed package via API. So, we will have to use some sort of workaround to find the deprecated components.

Here are some of the options:
1) Scrap the package detail page, which shows deprecated components with REST GET call from Apex

2) Build custom API on your packaging org which returns list of deprecated components. Call this API form VF page and get list of deprecated components

3) Maintain custom object (Eric Edit: - or Custom Metadata type) in your package that hold list deprecated components. Populate this object with post install script

Once we get the list deprecated components then its just matter of building destructive changes xml and calling deploy metadata API.

But the tricky part is we cant not call metadata API on same org so we will have take help of packing org again.

From VF page we will need to post destructive changes XML to packing org's custom API. This API can then build the required package to delete the components. After building the package packing org can call deploy api to delete the components.

https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls

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.