I know that I can use Metadata API and can use Apex to run Metadata API to delete metadata, like Custom Metadata records.
I know that I can leverage Metadata.Operations class to create or update Custom Metadata records.
What I struggle is to delete protected custom metadata record which was created by Metadata.Operations class from the managed package, since when I try to run this, I receive an error "No custom metadata named found". I tried to add namespace prefix and remove namespace prefix, but it doesn't work. Is there any workarounds or options for this?
The problem is that if we create protected custom metadata record in subscriber org and unable to delete it and refer to some custom field on subscriber org, then the subscriber will not be able to delete that custom field unless completely uninstalling our package, which is not the action we want to suggest to the customer.
I understand the problem is that Metadata API cannot access the protected metadata record from the package to delete that record.
Is there any elegant solution to this problem?