【发布时间】:2019-02-12 15:38:06
【问题描述】:
我使用 Web Resource JavaScript 文件从 CRM 中检索多条记录。
var fetchXML = `
<fetch mapping="logical" output-format="xml-platform" version="1.0" page="1">
<entity name="account" >
<attribute name="name" />
</entity>
</fetch>`;
var query = "accounts?fetchXml=" + fetchXML;
callWebAPI(query);
在第一个请求中获得 paging-cookie 后,我尝试将其发送到第二个请求以检索第二页的数据:
<fetch mapping="logical" output-format="xml-platform" version="1.0" page="2" paging-cookie="cookie i get from first request"
...
</fetch>`;
来自响应的原始 cookie 如下所示:
%253ccookie%2520page%253d%25221%2522%253e%253cname%2520last%253d%2522Deco%2520Voyages%2522%2520firstnull%253d%25221%2522%2520%252f%253e%253caccountid%2520last%253d%2522%257b9AFBEAA6-9EA7-E711-8103-70106FAA4841%257d%2522%2520first%253d%2522%257b0A86656D-BEA7-E711-8103-70106FAA4841%257d%2522%2520%252f%253e%253c%252fcookie%253e
我尝试根据文档转换和发送 cookie:https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/org-service/page-large-result-sets-with-fetchxml
var transformedCookie1 = GetDecodedCookie1(decodeURIComponent(decodeURIComponent(pagingcookie)));
var transformedCookie2 = GetDecodedCookie2(decodeURIComponent(decodeURIComponent(pagingcookie)));
function GetDecodedCookie1(cookie) {
return cookie.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
}
function GetDecodedCookie2(cookie) {
return cookie.replace(/</g, "%26lt;")
.replace(/>/g, "%26gt;")
.replace(/"/g, "%26quot;")
}
1) 在第一种情况下,当我使用 GetDecodedCookie1 时,我得到:
Script error. in at 0:0 null
我的查询字符串参数已损坏。
2) 在第二种情况下,当我使用 GetDecodedCookie1 查询字符串参数看起来不错但我得到:
Malformed XML in the Paging Cookie
这里有什么问题?
【问题讨论】:
-
你解决了吗?
-
很遗憾,即使我在 fetchXML 中添加帐户 ID,错误仍然存在。
标签: javascript xml dynamics-crm