使用条件仅获取fetchXml动态CRM查询中具有非数字值的记录

问题描述 投票:0回答:1

我正在使用fetchXML来查询DynamicCRM。我有一个实体,该实体的属性(placeName)的值是字符串或数字值。我希望有一个条件,即只能选择具有非数字值的记录。我没有在动力学文档中找到任何解决方案,但是也许有一种使用“开箱即用”(自定义条件)的解决方案。这是我当前的获取查询:

<fetch mapping="logical" distinct="true" varsion="1.0">
  <entity name="locations">
    <attribute name="placeID" />
    <attribute name="placeName" /> // This can be values like "home" or 100 - I would like to take out only those which are not a number
  </entiity>

dynamics-crm fetchxml
1个回答
0
投票

尽管我找不到任何地方的文档,但是您可以使用带有正则表达式语法的like运算符。

例如,以下查询将检索仅在其systemuser中包含数字的domainname记录:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
   <entity name="systemuser">
      <condition attribute="domainname" operator="like" value="%[0-9]%" />
   </entity>
</fetch>

并且在您的情况下,以下内容将仅检索字母a-z或A-Z的记录:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
   <entity name="locations">
      <condition attribute="placeName" operator="like" value="%[a-zA-Z]%" />
   </entity>
</fetch>
© www.soinside.com 2019 - 2024. All rights reserved.