dynamics-crm - 如何通过javascript或api在动态crm中通过文本搜索从多个实体中获取记录?
问题描述
我想通过匹配文本从多个实体中检索记录。是否可以使用 fetchxml 或 web api?我想通过javascript使用它。
解决方案
这当然可以使用 FetchXML 实现。具体来说,您想使用like运算符。例如,以下 Fetch Query 在联系人姓名和电子邮件中搜索给定值:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="contactid" />
<filter type="and">
<filter type="or">
<condition attribute="fullname" operator="like" value="%[Insert Dynamic Value]%" />
<condition attribute="emailaddress1" operator="like" value="%[Insert Dynamic Value]%" />
</filter>
</filter>
</entity>
</fetch>
为您要搜索的每个表编写一个类似的提取查询。
是否可以将所有实体组合在一起,而不是使用 fetchXml 单独请求?
不,根据设计,FetchXML 不支持查询多个不相关的记录。尽管您可以在单个 fetch 表达式中查询相关记录,但您无法跨多个表强制执行 OR 条件。例如,您不能编写类似于以下 SQL 的 FetchXML 查询:
SELECT *
FROM contact
JOIN account on contact.accountid = account.accountid
WHERE contact.fullname like '%foo%'
OR account.name like '%foo%'
推荐阅读
- google-cloud-platform - 使用 Google ML Engine 的预测时出现 ExpirationError
- java - 当 Marionette 通过 Selenium 3.12.0 变为 false 时,无法找到与 Firefox 匹配的一组功能
- session - Azure 服务总线 - 会话将消息复制到多个实例
- python - 使用 Pandas 和 SQLAlchemy 时出错
- angular - Angular 6 - HttpInterceptors - HttpResponse 正文没有被修改
- vue.js - 如何确认我使用的是 Vue 的“完整版本”?
- microsoft-graph-api - 使用 Microsoft Graph 登录的用户的图像 URL
- excel - Excel中具有搜索功能的多个IF语句
- php - 从 php 中的图像标签中过滤图像名称
- python - ImportError:没有名为“tensorflow.core”的模块