You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Dynamics 365使用Import Entity更新记录时参考属性映射错误求助

Fixing "This attribute is not mapped as a reference attribute" Error in Dynamics 365 Import Update

Let's break down what's causing this error and how to fix it. The error message spells out the core problem clearly: you’ve added a LookupMapping (the "ReferenceMap" mentioned in the error) for an attribute that hasn’t been marked as a reference/lookup type in your ColumnMapping. Dynamics 365 requires explicit flags for lookup fields before you can define match rules for them.

Step 1: Mark the ColumnMapping as a Lookup Attribute

For reference fields like systemuserid, you need to add two critical attributes to your ColumnMapping entity to flag it as a lookup:

  • IsLookup: Set this to true
  • SourceAttributeType: Set this to the lookup option in your attribute type enum

Here’s how to modify your existing column mapping code:

Entity colMapping = new Entity(CrmColumnmapping.EntityLogicalName);
colMapping.Attributes.Add(CrmColumnmapping.Fields.SourceAttributeName, dc.Caption);
colMapping.Attributes.Add(CrmColumnmapping.Fields.SourceEntityName, "MySource");
colMapping.Attributes.Add(CrmColumnmapping.Fields.TargetAttributeName, dc.ColumnName);
colMapping.Attributes.Add(CrmColumnmapping.Fields.TargetEntityName, dt.TableName);
// Add these two lines to mark the field as a lookup
colMapping.Attributes.Add(CrmColumnmapping.Fields.IsLookup, true);
colMapping.Attributes.Add(CrmColumnmapping.Fields.SourceAttributeType, 
    new OptionSetValue(CrmColumnmapping.OptionSets.SourceAttributeTypeValues.Lookup));
colMapping.Attributes.Add(CrmColumnmapping.Lookups.ImportMapId, new EntityReference(CrmImportmap.EntityLogicalName, importMap.Id));
colMapping.Attributes.Add(CrmColumnmapping.OptionSets.ProcessCode, new OptionSetValue(CrmColumnmapping.OptionSets.ProcessCodeValues.Option1_Process));
colMapping.Id = service.Create(colMapping);

Step 2: Verify Your LookupMapping Configuration

Your existing LookupMapping setup is on the right track for defining how to match source values to target lookup records:

  • The first LookupMapping uses Option2_System to specify the target entity’s matching attribute (e.g., systemuserid or domainname for the System User entity)
  • The second uses Option1_Source to define which source field holds the value to match on (e.g., a username or user ID from your input data)

Just double-check that the LookUpAttributeName values correspond to valid attributes on the target lookup entity (for the system mapping) and your source dataset (for the source mapping).

Step 3: Additional Checks for Update Imports

Since you’re running an update import, confirm these key details:

  1. Unique Matching Field: Ensure your import map includes a column mapping for a unique identifier (like the target entity’s primary key, e.g., accountid, or a custom unique field). Without this, Dynamics won’t know which existing record to update.
  2. ImportMap Update Setting: When creating your ImportMap, make sure you set its Update attribute to true (add importMap.Attributes.Add(CrmImportmap.Fields.Update, true); before creating the entity if you haven’t already). This enables the import map to support update operations.
  3. Import Mode: Your existing import code sets ModeCode to Option2_Update—that’s correct, keep this setting.

Example for systemuserid Mapping

If you’re specifically mapping to systemuserid, your LookupMapping values would look like this:

  • For the system lookup mapping:
    • LookUpEntityName: "systemuser"
    • LookUpAttributeName: "systemuserid" (or "domainname" if matching on the user’s email/domain)
  • For the source lookup mapping:
    • LookUpAttributeName: "Source_UserId" (the name of the column in your source data that holds the user identifier)

By adding the IsLookup and SourceAttributeType flags to your column mapping, you’ll resolve the inconsistency error and let your lookup mapping rules work correctly for the update import.

内容的提问来源于stack exchange,提问作者Jérémie Huart

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:25:08