Search code examples
metadatadynamics-crm

Use MetdataId to find the Attribute Name of a deleted attribute


When I query the metadata using RetrieveMetadataChangesRequest, the RetrieveMetadataChangesResponse returns EntityMetadata and DeletedMetadata. The DeletedMetadata only returns the MetadataId.

Is there a way to get the metadata for the attribute without knowing the entity? Even just the attribute name would be fine.

RetrieveAttributeRequest I think only works if the attribute exists and if you have the entitylogicalname.


Solution

  • No, the only infomration available is the MetadataId.

    Quoting from the SDK:

    This collection is a dictionary of GUID values using a DeletedMetadataFilters as a key. The GUID values represent MetadataId values of the metadata items.

    Looking at another part of the SDK specifically addresses this question:

    You will also use DeletedMetadataFilters enumeration as a key to the RetrieveMetadataChangesResponse.DeletedMetadata to filter the GUID values found in the RetrieveMetadataChangesResponse.DeletedMetadata property. When you design a metadata cache you will want to use the MetadataId for each item so that you can identify deleted metadata items and remove them.

    So as a developer you are expected to populate a cache of metadata of interest to your application. You can query the CRM Metadata to find changes and deletes - but in the case of a delete you are responsible for having collected the metadata in your cache.