sql
  • crm
  • bids
  • dynamics-crm-online
  • fetchxml
  • 2014-07-10 36 views 0 likes 
    0

    我有一個FetchXml報表在CRM Online 2013上運行,有大約12,000條記錄。數據通過腳本從CRM Online轉移到SQL數據庫。我希望當前修改的記錄只能轉移到SQL。這是我的查詢FetcXml會一直搜索前5000條記錄嗎?

    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. 二,將 提取XML總是查詢前5000個記錄?如果這個變化是 怎麼辦?可以說,在第6000條記錄中,它也會被查詢嗎?

    回答

    1

    您可以通過修改日期降序來訂購,然後通過更改如下所示的獲取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> 
    
    +0

    那麼這是我的問題,它只會始終查詢第5000條記錄?如果第6000條記錄改變了怎麼辦? – hkhan

    +0

    您正在按修改日期降序檢索記錄訂單。所以第一個記錄將是最後更新的記錄。 –

    +0

    哦,太棒了。讓我測試一下。如果這有效,你就解決了一個巨大的問題 – hkhan

    相關問題