0

I would like to know if I deployed metadata to a customer's instance via the metadata api, is it possible to create a script to delete said metadata out via the metadata api?

I see a couple of posts that look promising but I would selfishly like to get a confirmation on my question here :)

I also see that there is a destructiveChanges.xml file that you can use, but for my use case I rather do the deletion from the API.

Post from 2014: Is there a list of every possible metadata component?

1

1 Answer 1

1

From a technical standpoint, yes - as Phil W. said in a comment, you can use a destructive deployment to remove components via the Metadata API.

However, this is a very dangerous idea.

Deleting unmanaged metadata from a customer org has the potential for a huge variety of side effects.

  • It may simply fail, if the customer has created other components that reference the ones you're trying to delete.
  • It may break the customer's dynamic Apex or dynamic SOQL, if applicable.
  • It may cause behavior changes that break the customer's Apex and Flow automation or Apex unit tests.
  • It may cause breakage in the customer's integrated systems, if they rely on those components or are sensitive to (for example) schema changes.
  • It might even place other dependent components built by the customer in a broken or inconsistent state, in rare cases. The platform doesn't always enforce component-to-component referential integrity at 100%.

So even if you perform this operation with the customer's full understanding and consent, you risk causing a variety of negative side effects for your customers. You're going to end up being de facto on the hook for that breakage, because your system was the precipitating cause, which is likely going to make your support staff unhappy and potentially damage your reputation.

We haven't even touched on the implications for change management and compliance requirements for your customers who operate in regulated industries!


If you don't perform this operation with the customer's full understanding and consent - if, for example, you're attempting to establish some kind of misguided IP protection on unmanaged components - what you are building would be malware, would violate customer trust, and may have any number of other serious legal and practical implications. If that's the case, I would encourage you in the strongest possible terms to abandon this line of inquiry.

2
  • that is not my intention at all and this would be covered contractually. I do appreciate your input! Just trying to learn the limitation with the Metadata API. As always, thank you for your responses and feedback, I am learning alot from this community.
    – andrew
    Dec 30, 2022 at 17:28
  • 1
    Thank you for clarifying! I still think that this is an extremely high risk implementation even if done for high-minded reasons. As an engineer, I would seriously consider whether I could implement this feature without exposing myself to legal and professional risk.
    – David Reed
    Dec 30, 2022 at 17:59

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