正在将数据从 Dynamics CRM 加载到 SQL 服务器

Loading Data from Dynamics CRM to SQL Server

无法使用 Azure 数据工厂将选项集字符串从 Dynamics CRM 获取到 SQL 服务器。

我正在使用 Azure 数据工厂将数据从 Dynamics CRM 移动到 SQL 数据库。我使用 fetchXML 查询从源 (CRM) 获取数据。我能够毫无问题地获得正常的字符串和 guid 类型值。

但是来自 CRM 的选项集字段是 Int32 类型(即,我得到的是选项集的值,而不是字符串)。

我该如何解决这个问题?

可能您正在使用 this approach 获取 fetchxml 结果集作为动态源以使用 Azure 数据工厂转储到 SQL。您面临的问题是无法使用该选项列表选项的格式化文本值。

我们将在代码中使用以下语法使用格式化值:Reference

//Option set
var industrycodeValue = accountDetails['industrycode'];

var industrycodeTextValue = accountDetails['industrycode@OData.Community.Display.V1.FormattedValue'];

如果你不能这样做,那么最好在你的 SQL 中转储另一个 table 称为 stringmap 它将存储整个系统的所有选择列表选项。

然后您可以内部连接两个 table 以获得必要的数据。

select INC.TicketNumber[Case ID],SMT.Value[Status Name], SMT.AttributeValue[Status Value]
from incident as INC inner join StringMap as SMT
on INC.StatusCode = SMT.AttributeValue
where SMT.AttributeName='statuscode' and SMT.ObjectTypeCode=112

Read more

我也必须同步 stringmaps 实体,因为我超过了给定 FetchXML 查询的 link-entity 限制。

以下将引入 OptionSet 选择的文本值。

    <link-entity name="stringmap" from="attributevalue" to="____" visible="false" link-type="outer" alias="____">
        <filter type="and">
            <condition attribute="objecttypecode" operator="eq" value="___"/>
        </filter>
        <attribute name="value"/>
    </link-entity>

to 应该是 host/root 实体上的 OptionSet 列的名称

alias 无论您想在输出中调用该列。我使用与 to

相同的值

这是您的 host/root 实体的对象类型代码。它是一个整数值。