FetchXML Tutotorial

How to use like and not like operator in FetchXML

In this blog we will learn How to use like and not like operator in FetchXML?

Use like and not like operator in FetchXML

The LIKE operator is used to search for a specified pattern in a column.

Generally There are two wildcards often used in conjunction with the LIKE operator:

1. The percent sign (%) represents zero, one, or multiple characters
2. The underscore sign (_) represents one, single character

FetchXML LIKE Examples

The following FetchXML selects all customers with a CustomerName starting with “a”:

<fetch mapping="logical" version="1.0">
  <entity name="customers">
    <all-attributes />
    <filter>
      <condition attribute="customername" operator="like" value="a%" />
    </filter>
  </entity>
</fetch>

FetchXML Not LIKE operator Examples

The following fetchxml selects all customers with a CustomerName that does NOT start with “a”:

<fetch mapping="logical" version="1.0">
  <entity name="customers">
    <all-attributes />
    <filter>
      <condition attribute="customername" operator="not-like" value="a%" />
    </filter>
  </entity>
</fetch>

Leave a Reply

Your email address will not be published. Required fields are marked *