我在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数据库。这个问题有两个部分:
如何更改查询以便它带来最新的修改记录 而是在最后两分钟修改过的那个?
第二,将 获取XML总是查询前5,000条记录?如果改变了怎么办? 让我们说,在第6,000条记录中,它也会被查询吗?
答案 0 :(得分:1)
您可以按修改日期降序排序,然后通过更改fetch xml来获取第一条记录,如下所示。还可以通过添加count =&#34;&#34;属性可以控制检索的记录数。我觉得有最大值。可能有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>