2016-12-12 7 views
0

У меня есть более 5000 записей, которые я хочу получить с помощью этого запроса, но каждый раз получаю cookie с нулевым значением. Я понял, что связанный объект является проблемой здесь, потому что когда я его удаляю, я получаю cookie каждый раз.CRM FetchXML извлекает более 5000 записей

<fetch version="1.0" mapping="logical" distinct="true" page="1" count="2000" > 
    <entity name="listmember" > 
     <link-entity name="contact" from="contactid" to="entityid" alias="c" > 
      <attribute name="contactid" /> 
      <attribute name="telephone1" /> 
      <link-entity name="phonecall" from="ic_customer" to="contactid" alias="pc" link-type="outer" distinct="true"> 
       <attribute name="activityid" /> 
       <filter type="and" > 
        <filter type="or" > 
         <condition attribute="statuscode" operator="eq" value="1" /> 
         <condition attribute="ic_end" operator="on-or-after" value="2016-11-12" /> 
        </filter> 
       </filter> 
      </link-entity> 
      <filter type="and" > 
       <condition attribute="statecode" operator="eq" value="0" /> 
       <condition attribute="telephone1" operator="not-null" /> 
       <condition attribute="donotphone" operator="eq" value="0" /> 
      </filter> 
     </link-entity> 
     <filter type="and" > 
      <condition attribute="listid" operator="in" > 
       <value> 
        {f89087ef-7017-e611-80e3-5065f38a3951} 
       </value> 
      </condition> 
      <condition entityname="pc" attribute="activityid" operator="null" /> 
     </filter> 
    </entity> 
</fetch> 

Кто-нибудь знает, как получить пейджинг-файл с этим запросом?

ответ

0

Решение этой проблемы заключается в том, что вам нужно указать столбец идентификатора в корневом сущности. В этом примере вам нужно добавить атрибут listmemberid к корню listmember.

<fetch version="1.0" mapping="logical" distinct="true" page="1" count="2000" > 
    <entity name="listmember" > 
     <attribute name="listmemberid" /> 
     <link-entity name="contact" from="contactid" to="entityid" alias="c" > 
      <attribute name="contactid" /> 
      <attribute name="telephone1" /> 
      <link-entity name="phonecall" from="ic_customer" to="contactid" alias="pc" link-type="outer" distinct="true"> 
       <attribute name="activityid" /> 
       <filter type="and" > 
        <filter type="or" > 
         <condition attribute="statuscode" operator="eq" value="1" /> 
         <condition attribute="ic_end" operator="on-or-after" value="2016-11-12" /> 
        </filter> 
       </filter> 
      </link-entity> 
      <filter type="and" > 
       <condition attribute="statecode" operator="eq" value="0" /> 
       <condition attribute="telephone1" operator="not-null" /> 
       <condition attribute="donotphone" operator="eq" value="0" /> 
      </filter> 
     </link-entity> 
     <filter type="and" > 
      <condition attribute="listid" operator="in" > 
       <value> 
        {f89087ef-7017-e611-80e3-5065f38a3951} 
       </value> 
      </condition> 
      <condition entityname="pc" attribute="activityid" operator="null" /> 
     </filter> 
    </entity> 
</fetch> 
0

Чтение сообщения напоминало мне, что я слышал об этом раньше, и, конечно же, я пошел к своим заметкам и увидел, что «Fetchxml со связностью не поддерживает пейджинг». Однако я не могу найти официальную информацию об ограничении, которая кажется странной.

В любом случае, я уверен, что это случай, когда выборки запросов с объектами ссылок не поддерживают пейджинг. Попробуйте выполнить с помощью QueryExpression.

-1
using System; 
using System.Data; 
using Microsoft.SqlServer.Dts.Pipeline.Wrapper; 
using Microsoft.SqlServer.Dts.Runtime.Wrapper; 
using Microsoft.Xrm.Sdk; 
using System.ServiceModel.Description; 
using Microsoft.Xrm.Sdk.Client; 
using Microsoft.Xrm.Sdk.Query; 

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] 
public class ScriptMain : UserComponent 
{ 
    IOrganizationService organizationservice; 

    public override void PreExecute() 
    { 
     base.PreExecute(); 

     ClientCredentials credentials = new ClientCredentials(); 

     credentials.UserName.UserName = "username"; 

     credentials.UserName.Password = "password"; 


     credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; 

     organizationservice = new OrganizationServiceProxy(
      new Uri("_your org service_Organization.svc"), null, credentials, null); 
    } 

    public override void PostExecute() 
    { 
     base.PostExecute(); 
    } 

    public override void CreateNewOutputRows() 
    { 
     QueryExpression query = new QueryExpression("account") 
     { 
      ColumnSet = new ColumnSet(new string[] { "accountnumber" }), 
      PageInfo = new PagingInfo() 
      { 
       Count = 250, 
       PageNumber = 1, 
       ReturnTotalRecordCount = false, 
       PagingCookie = null 
    } 
     }; 

     EntityCollection results = null; 

     while (true) 
     { 



      results = organizationservice.RetrieveMultiple(query); 

      foreach (Entity record in results.Entities) 
      { 
       accountBuffer.AddRow(); 


       if (record.Contains("accountnumber")) 
        accountBuffer.accountnumber = record.GetAttributeValue<string>("accountnumber"); 


      } 



      if (results.MoreRecords) 
      { 
       query.PageInfo.PageNumber++; 
       query.PageInfo.PagingCookie = results.PagingCookie; 
      } 
      else 
      { 
       break; 
      } 
     } 

    } 




} 
+0

пытаются объяснить код. – Gahan