【问题标题】:Will FetcXml always search the first 5000 records?FetcXml 是否总是搜索前 5000 条记录?
【发布时间】:2014-08-31 23:02:40
【问题描述】:

我有一个在 CRM Online 2013 上运行的 FetchXml 报告,其中包含大约 12,000 条记录。数据通过脚本从 CRM Online 转移到 SQL 数据库。我希望将当前修改的记录仅转移到 SQL。这是我的查询

string fetchXml = string.Format(
    @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
        <entity name='new_studentinformation' enableprefiltering ='1' prefilterparametername='CRM_Filterednew_studentinformation'>
            <attribute name='new_studentid' />
            <attribute name='new_primaryhomeroom' />
            <attribute name='new_lastname' />
            <attribute name='new_firstname' />
            <attribute name='new_busnumber' />
            <attribute name='new_building' />
            <attribute name='new_grade' />
            <attribute name='modifiedon' />
            <attribute name='new_studentinformationid' />
            <filter type='and'>
                <condition attribute='modifiedon' value='{0}' operator='on-or-after'/>
            </filter>
            <link-entity name='annotation' from='objectid' to='new_studentinformationid' alias='Notes' link-type='outer'>
                <attribute name='documentbody'/>
            </link-entity>
        </entity>
    </fetch>",
    DateTime.Now.AddMinutes(-2).ToString());

这会查询最近两分钟内修改的记录并将其转移到 SQL 数据库。问题分为两部分:

  1. 如何更改查询以便它带来最新的修改记录 而不是最后两分钟修改的那个?

  2. 第二,将 Fetch XML 总是查询前 5,000 条记录?如果改变是什么 比方说,在第 6000 条记录时,它也会被查询吗?

【问题讨论】:

    标签: sql crm bids dynamics-crm-online fetchxml


    【解决方案1】:

    您可以按修改后的日期降序排序,然后通过更改 fetch xml 来获取第一条记录,如下所示。此外,通过添加 count="" 属性,您可以控制检索的记录数。我认为有最大值。可能有 5000 条记录。

    <fetch version='1.0' output-format='xml-platform' count="5000" page="1" no-lock="false"  mapping='logical' distinct='false'>
      <entity name='new_studentinformation' enableprefiltering ='1' prefilterparametername='CRM_Filterednew_studentinformation'>
        <attribute name='new_studentid' />
        <attribute name='new_primaryhomeroom' />
        <attribute name='new_lastname' />
        <attribute name='new_firstname' />
        <attribute name='new_busnumber' />
        <attribute name='new_building' />
        <attribute name='new_grade' />
        <attribute name='modifiedon' />
        <attribute name='new_studentinformationid' />
        <filter type='and'>
          <condition attribute='modifiedon' value='{0}' operator='on-or-after'/>
        </filter>
        <order attribute='modifiedon' descending='true' />
        <link-entity name='annotation' from='objectid' to='new_studentinformationid' alias='Notes' link-type='outer'>
          <attribute name='documentbody'/>
        </link-entity>
      </entity>
    </fetch>
    

    【讨论】:

    • 那是我的问题,它只会查询前 5000 条记录吗?如果第 6000 条记录发生变化怎么办?
    • 您正在按 modifieddate 降序检索记录。所以第一条记录将是最后更新的记录。
    • 哦,太好了。让我测试一下。如果这行得通,你就解决了一个大问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多