Search code examples
dynamics-crmmicrosoft-dynamicsfetchxml

Dynamics FetchXML condition checking text field beginning with pattern "xxABC"


In Microsoft Dynamics 365 FetchXML, is there a way to check a text field with the condition that it begins with "xxABC", where "xx" can be anything?


Solution

  • This is actually possible (to my surprise).

    I created a few Account records, named:

    • "aacd"
    • "abcde"
    • "zxcdef"

    Using _ as the placeholder for single characters I got the desired result:

    <fetch top="50">
      <entity name="account">
        <attribute name="name" />
        <filter>
          <condition attribute="name" operator="like" value="__cd%" />
        </filter>
      </entity>
    </fetch>
    

    Under the hood this like condition appears to be translated into T-SQL. Take a look at the documentation LIKE (Transact-SQL) and have fun!