javascript - 使用 FetchXML 条件编写 RetrieveMultiple 查询

标签 javascript soap dynamics-crm-2011

我在 MS CRM 2011 中使用新的 OrganizationService 端点 - /XRMServices/2011/Organization.svc

它似乎不支持旧的Fetch命令。我发现我仍然可以通过将 fetchXML 查询传递给 RetrieveMultiple 方法来使用它。

在 C# 中,它看起来确实很简单:

string expression = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='systemuser'>
<attribute name='businessunitid' />
<attribute name='systemuserid' />
<order attribute='businessunitid' descending='false' />
<filter type='and'>
<condition attribute='systemuserid' operator='eq-userid' />
</filter>
<link-entity name='businessunit' from='businessunitid' to='businessunitid' alias='ah'>
<attribute name='name' />
</link-entity>
</entity>
</fetch>";

FetchExpression fetch = new FetchExpression(expression);
// let's assume GetOrganisationService will return correct instance of IOrganizationService
IOrganizationService service = GetOrganisationService();
EntityCollection result = service.RetrieveMultiple(fetch);

但我需要通过 JavaScript 执行同样的操作。我不太确定在这种情况下如何编写正确的查询。

显然,fetchXML需要以某种方式转换为SOAP,但我刷遍了互联网和SDK,找不到如何做到这一点的方法.

我怎样才能提出这样的请求:

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='systemuser'>
<attribute name='businessunitid' />
<attribute name='systemuserid' />
<order attribute='businessunitid' descending='false' />
<filter type='and'>
<condition attribute='systemuserid' operator='eq-userid' />
</filter>
<link-entity name='businessunit' from='businessunitid' to='businessunitid' alias='ah'>
<attribute name='name' />
</link-entity>
</entity>
</fetch>

在以下 SOAP 消息中?

<soap:Body>
<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>
<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:QueryExpression'>

Some magic here

</RetrieveMultiple>
</soap:Body>

最佳答案

设置 c 所需的代码 all the SOAP Retrieve multiple via SOAP from JavaScript相当冗长。

您的查询足够简单...您不使用 OData 休息调用有什么原因吗?

关于javascript - 使用 FetchXML 条件编写 RetrieveMultiple 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15666098/

相关文章:

c# - SugarCRM Soap 的 get_entry_list 方法

php - 安装 SOAP 后没有 soap.so PHP 模块文件

dynamics-crm-2011 - 在线和内部部署的通用解决方案?

dynamics-crm-2011 - 如何在 CRM 2011 插件中阅读电子邮件正文

javascript - 如何使用 javascript 进行跨域 http get 请求?

Javascript 文件出现语法错误

javascript - 我应该如何对这个简单的 javascript 动画进行逆向工程?

mysql - 如何在 Talend 中将 mysql 数据公开为 SOAP Web 服务

php - 使用 javascript 和 php 显示日历

javascript - 在 jQuery 语法中使用 CSS 错误属性名称包含破折号字符