Friday, 27 July 2018

D365 - The attribute with AttributeId = 'Guid' was not found in the MetadataCache - MSCRM Solution Export


Error Message during solution export:
The attribute with AttributeId = <GUID> was not found in the MetadataCache.


Root Cause:
A field is deleted from CRM and the field is removed. But the related solution component reference is left behind somehow.


Fix:
Find the component related to the field and remove it.

Note: Make sure to have a back-up of DB or the Org before performing below operations. Need developer level knowledge to perform this!

Step 1: Find the missing component. Get the solutioncomponentid and componenttype by executing the following fetchxml  query after replacing the guid with the attributeid from the error message.

Note: You can XRM toolbox or C# console app to retrieve the record

<fetch top="50" >
  <entity name="solutioncomponent" >
    <all-attributes/>
    <filter type="and" >
      <condition attribute="objectid" operator="eq" value="<GUID>" />
    </filter>
  </entity>
</fetch>

Step 2: Get the "solutioncomponentid" and "componenttype"  from the result of above fetchxml query and use "RemoveSolutionComponentRequest" to remove the component.



var removeComponentReq = new RemoveSolutionComponentRequest()
{
    ComponentId = <GUID - objectid>,
    ComponentType = <int - componenttype>,
    SolutionUniqueName = <string - solution's uniquename>
};

Hope this helps!

9 comments:

  1. For me, it only worked after executing below request.
    var removeComponentReq = new RemoveSolutionComponentRequest()
    {
    ComponentId = ,
    ComponentType = ,
    SolutionUniqueName =
    };
    Thanks.

    ReplyDelete
  2. I have to put objectid from fetchxml instead of solutioncomponentid to get it work

    ReplyDelete
  3. Kindly tell me assembly reference name ?

    ReplyDelete
    Replies
    1. RemoveSolutionComponent request and response is available under below assembly and namespace

      Namespace:Microsoft.Crm.Sdk.Messages
      Assembly:Microsoft.Crm.Sdk.Proxy.dll

      Delete
  4. Hi Ram, what do you use in the XRM Toolbox to run the RemoveSolutionComponentRequest?

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. How to get "componenttype" from the solution using c# console app

    ReplyDelete
  7. I believe you can use the first fetchxml query in the blog. Alternatively you can use the below table from MS docs

    TABLE 2
    Value Label
    1 Entity
    2 Attribute
    3 Relationship
    4 Attribute Picklist Value
    5 Attribute Lookup Value
    6 View Attribute
    7 Localized Label
    8 Relationship Extra Condition
    9 Option Set
    10 Entity Relationship
    11 Entity Relationship Role
    12 Entity Relationship Relationships
    13 Managed Property
    14 Entity Key
    16 Privilege
    17 PrivilegeObjectTypeCode
    20 Role
    21 Role Privilege
    22 Display String
    23 Display String Map
    24 Form
    25 Organization
    26 Saved Query
    29 Workflow
    31 Report
    32 Report Entity
    33 Report Category
    34 Report Visibility
    35 Attachment
    36 Email Template
    37 Contract Template
    38 KB Article Template
    39 Mail Merge Template
    44 Duplicate Rule
    45 Duplicate Rule Condition
    46 Entity Map
    47 Attribute Map
    48 Ribbon Command
    49 Ribbon Context Group
    50 Ribbon Customization
    52 Ribbon Rule
    53 Ribbon Tab To Command Map
    55 Ribbon Diff
    59 Saved Query Visualization
    60 System Form
    61 Web Resource
    62 Site Map
    63 Connection Role
    64 Complex Control
    70 Field Security Profile
    71 Field Permission
    90 Plugin Type
    91 Plugin Assembly
    92 SDK Message Processing Step
    93 SDK Message Processing Step Image
    95 Service Endpoint
    150 Routing Rule
    151 Routing Rule Item
    152 SLA
    153 SLA Item
    154 Convert Rule
    155 Convert Rule Item
    65 Hierarchy Rule
    161 Mobile Offline Profile
    162 Mobile Offline Profile Item
    165 Similarity Rule
    66 Custom Control
    68 Custom Control Default Config
    166 Data Source Mapping
    201 SDKMessage
    202 SDKMessageFilter
    203 SdkMessagePair
    204 SdkMessageRequest
    205 SdkMessageRequestField
    206 SdkMessageResponse
    207 SdkMessageResponseField
    210 WebWizard
    18 Index
    208 Import Map
    300 Canvas App
    371 Connector
    372 Connector
    380 Environment Variable Definition
    381 Environment Variable Value
    400 AI Project Type
    401 AI Project
    402 AI Configuration
    430 Entity Analytics Configuration
    431 Attribute Image Configuration
    432 Entity Image Configuration

    ReplyDelete