uba*_*012 5 dynamics-crm odata dynamics-crm-online dynamics-crm-webapi dynamics-crm-365
是否可以计算给定实体中的所有行,绕过 5000 行限制并绕过页面大小限制?
我不想在一个请求中返回超过 5000 行,但只想要该给定实体中所有行的计数。
根据 Microsoft 的说法,您不能在请求 URI 中执行此操作:
The count value does not represent the total number of entities in the system. 
It is limited by the maximum number of entities that can be returned.
我已经尝试过这个:
GET [Organization URI]/api/data/v9.0/accounts/?$count=true
还有其他办法吗?
如果要检索超过 5000 条的实体的记录总数,请使用 RetrieveTotalRecordCount 函数。
您的查询将如下所示:
https://<your api url>/RetrieveTotalRecordCount(EntityNames=['accounts'])
更新:
\n\n最新版本 v9.1 具有实现此目的的直接函数 - RetrieveTotalRecordCount
\n\n\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2 \x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80 \x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94
\n\n不幸的是,我们必须选择其中一种路线来根据限制内的预期结果来确定记录数。
\n\n1.如果小于5000,使用这个:(你已经尝试过这个)
\n\nGET [Organization URI]/api/data/v9.0/accounts/?$count=true\n2. 小于50,000,使用这个:
\n\nGET [Organization URI]/api/data/v8.2/accounts?fetchXml=[URI-encoded FetchXML query]\n超过限制会报错:AggregateQueryRecordLimit exceeded. Cannot perform this operation.
示例查询:
\n\n<fetch version="1.0" mapping="logical" aggregate="true">\n  <entity name="account">\n    <attribute name="accountid" aggregate="count" alias="count" />\n  </entity>\n</fetch>\n使用 URI 进行浏览器地址栏测试:
\n\n[Organization URI]/api/data/v8.2/accounts?fetchXml=%3Cfetch%20version=%221.0%22%20mapping=%22logical%22%20aggregate=%22true%22%3E%3Centity%20name=%22account%22%3E%3Cattribute%20name=%22accountid%22%20aggregate=%22count%22%20alias=%22count%22%20/%3E%3C/entity%3E%3C/fetch%3E\n\n\n\n\n\n解决这个问题的唯一方法是根据某些属性对数据集进行分区,以便获得较小的记录子集来单独聚合。
\n
3. 最后的手段是使用代码变量迭代@odata.nextLink并计算每个页面中的记录(查询下一页的代码示例)
| 归档时间: | 
 | 
| 查看次数: | 12793 次 | 
| 最近记录: |