Azure数据工厂复制数据-无法将'System.String'转换为目标类型'Microsoft.Xrm.Sdk.EntityReference'

时间:2020-06-05 17:06:06

标签: azure-data-factory

我正在尝试在Azure数据工厂中的复制数据操作中设置查找字段。

我得到的错误是

Failure happened on 'Sink' side. ErrorCode=UserErrorTypeConversionFail,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,
Message=,Source=,''Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=The 
attribute 'ks_supervisor' with value 'E3BEFA28-C7A6-EA11-A812-000D3A1BB8EF' cannot be converted from 
original type 'System.String' to target type 'Microsoft.Xrm.Sdk.EntityReference'.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Sy
stem.InvalidCastException,Message=Specified cast is not 
valid.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Microsoft.DataTransfer.Common.Sh
ared.HybridDeliveryException,Message=The attribute 'ks_supervisor' with value 'E3BEFA28-C7A6-EA11-A812-
000D3A1BB8EF' cannot be converted from original type 'System.String' to target type 
'Microsoft.Xrm.Sdk.EntityReference'.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Sy
stem.InvalidCastException,Message=Specified cast is not 
valid.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,

关键部分是value 'E3BEFA28-C7A6-EA11-A812-000D3A1BB8EF' cannot be converted from original type 'System.String' to target type 'Microsoft.Xrm.Sdk.EntityReference'

我的问题是,如果期望D365 / CDS / CRM中的EntityReference类型的值,如何在其中设置查找字段值?

我已经尝试过CDS连接器,Dynamics 365和CRM连接器,但是都导致相同的错误。我还寻找了尝试将源值从字符串转换为GUID的方法,但是我找不到方法,我不知道这是否有帮助,因为它是GUID而不是EntityReference。源列来自类型为“ uniqueidentifier”的SQL表,但它会自动投影到字符串。

1 个答案:

答案 0 :(得分:0)

我必须在列映射的目标列名称中添加“ @EntityReference”。请在此处查看MSFT提供的答案:https://docs.microsoft.com/en-us/answers/questions/34069/azure-data-factory-copy-data-to-cds-cannot-convert.html?childToView=34732#comment-34732

请参阅此处的文档,以设置查找列的值。它还显示了如何设置客户列值:https://docs.microsoft.com/en-us/azure/data-factory/connector-dynamics-crm-office-365#writing-data-to-lookup-field