How to Use the 'Like' Keyword in X++

March 5, 2025

By: Jessica Burkhart

If you're familiar with SQL, you probably know the 'like' keyword and its use of the % wildcard character for filtering data. But did you know that you can also use the 'like' keyword in X++? In X++, the * symbol serves as the wildcard character, allowing you to filter data in a similar way.

Example in X++:

like keyword in X++

But what if you want to filter a data entity or an AOT query using the 'like' keyword? Here's a step-by-step guide to help you achieve that.

Filtering a Data Entity or AOT Query

  1. Add a Range to the Datasource: Start by adding a range to the datasource containing the filter field.
  2. Set the Filter Field: Set the filter field to the field you want to filter on.
  3. Use the Correct Syntax: Use the following syntax to provide the filter value:
    (<fieldname> like " <filtercriteria>*")

* Note: Make sure to use parentheses around the entire statement and use double quotes around your filter criteria.

Example:

like keyword in X++

This same syntax can also be applied to AOT query ranges, making it a versatile tool for filtering data in X++.

Conclusion

Incorporating the 'like' keyword into your X++ queries can significantly improve your ability to filter and manage data efficiently. Whether you're working with data entities or AOT queries, mastering this technique will make your code more flexible. Keep experimenting with different filter criteria and ranges to see how you can best leverage this feature in your projects!

Interested in learning more about how Strabo Partners can be your implementation partner? Contact us today!