{"title":"Using filter expressions in OData URIs","url":"https://jonas-paprotka.de/docs/dev-itpro/webservices/use-filter-expressions-in-odata-uris/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-filter-expressions-in-odata-uris, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-filter-expressions-in-odata-uris","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn how to use filter expressions in OData URIs to limit results, map to AL filters, and see syntax examples.","date":"2025-06-20","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Using filter expressions in OData URIs","slug":"using-filter-expressions-in-odata-uris","at":0,"chars":5005},{"level":2,"title":"Filter expressions","slug":"filter-expressions","at":320,"chars":3885},{"level":3,"title":"Filters without equivalent AL expressions","slug":"filters-without-equivalent-al-expressions","at":3754,"chars":451},{"level":2,"title":"Referencing different data types in filter expressions","slug":"referencing-different-data-types-in-filter-expressions","at":4205,"chars":226},{"level":2,"title":"Nested function calls","slug":"nested-function-calls","at":4431,"chars":421},{"level":2,"title":"Related information","slug":"related-information","at":4852,"chars":153}],"text":"# Using filter expressions in OData URIs\nYou use filter expressions in OData URIs to limit the results in a returned document. This article lists the filter expressions, and describes the equivalent field or table filter in AL. It provides examples of syntax for using filter expressions in OData URIs and applications.\n## Filter expressions\nTo add a filter to an OData URI, add `$filter=` to the end of the name of the published web service. For example, the following URI filters the City field in the Customer page to return all customers who are located in Miami:\n```https\nhttps://localhost:7048/BC240/ODataV4/Company('CRONUS International Ltd.')/Customer?$filter=City eq 'Miami'\n```\nThe following table shows the filters that are supported in Business Central OData web services and their equivalent AL filter expressions. All examples are based either on page 21, Customer \\(published as Customer\\), or on page 20, General Ledger Entry \\(published as GLEntry\\).\n|Definition|Example and explanation|Equivalent AL expression|\n|Select a range of values|`$filter=Entry_No gt 610 and Entry_No lt 615`<br /><br /> Query on GLEntry service. Returns entry numbers 611 through 614.|`..`|\n|In a list of values|`$filter=EntryNo in (610, 612, 614)`<br /><br /> Query that returns entry numbers 610, 612, and 614<br><br>Note: This only works in `$schemaversion=2.1`.||\n|And|`$filter=Country_Region_Code eq 'ES' and Payment_Terms_Code eq '14 DAYS'`<br /><br /> Query on Customer service. Returns customers in Spain where Payment_Terms_Code=14 DAYS.|`&`|\n|Or|`$filter= Country_Region_Code eq 'ES' or Country_Region_Code eq 'US'`<br /><br /> Query on Customer service. Returns customers in Spain and the United States.<br /><br /> Alert: You can use OR operators to apply different filters on the same field. However, you can't use OR operators to apply filters on two different fields.|`&#124;`|\n|Less than|`$filter=Entry_No lt 610`<br /><br /> Query on GLEntry service. Returns entry numbers that are less than 610.|`<`|\n|Greater than|`$filter= Entry_No gt 610`<br /><br /> Query on GLEntry service. Returns entry numbers 611 and higher.|`>`|\n|Greater than or equal to|`$filter=Entry_No ge 610`<br /><br /> Query on GLEntry service. Returns entry numbers 610 and higher.|`>=`|\n|Less than or equal to|`$filter=Entry_No le 610`<br /><br /> Query on GLEntry service. Returns entry numbers up to and including 610.|`<=`|\n|Different from \\(not equal\\)|`$filter=VAT_Bus_Posting_Group ne 'EXPORT'`<br /><br /> Query on Customer service. Returns all customers with VAT_Bus_Posting_Group not equal to EXPORT.|`<>`|\n|endswith|`$filter=endswith(VAT_Bus_Posting_Group,'RT')`<br /><br /> Query on Customer service. Returns all customers with VAT_Bus_Posting_Group values that end in 'RT'.|`*`|\n|startswith|`$filter=startswith(Name, 'S')`<br /><br /> Query on Customer service. Returns all customers names beginning with 'S'.|`*`|\n|contains|`$filter=contains(Name, 'urn')`<br /><br /> Query on Customer service. Returns customer records for customers with names containing the string urn.||\n|substring|`$filter=substring(Location_Code, 5) eq 'RED'`<br /><br /> Query on Customer service. Returns true for customers with the string RED in their location code starting as position 5.||\n|tolower|`$filter=tolower(Location_Code) eq 'code red'`||\n|toupper|`$filter=toupper(FText) eq '2ND ROW'`||\n> NOTE\n> These filters are more robust and more flexible in `$schemaversion=2.1`.\n> NOTE\n> There's a special filter, journals.templateDisplayName, which returns default journals if a user doesn't define the filter criteria.\n> NOTE\n> You can learn more about setting the filters that are specific to AL language by checking out ../developer/devenv-entering-criteria-in-filters article.\n### Filters without equivalent AL expressions\nFor filters that don't have equivalent AL expressions, the platform uses the closest available AL approximation. For example, tolower and toupper disable case sensitivity in comparisons, and substring gets turned into `*` wild card operators.\nIf there's no AL approximation, an error is reported. For example, an error can occur if you perform Or over different fields, like `field1 eq 1 or field2 eq 2`.\n## Referencing different data types in filter expressions\nUse the appropriate notation for different data types with filter expressions.\n Delimit string values by single quotation marks.\n Numeric values require no delimiters.\n## Nested function calls\nNested function calls in filter clauses are supported in `$schemaversion=2.1` and later. Nested function calls aren't supported in earlier schema versions, which means that filter clause expressions like `contains(tolower(field), 'some')` don't return the expected results. In this case, a partial case-insensitive text search - but instead either throws an error or returns an undefined result.\n## Related information\nodata-web-services\nMicrosoft OData docs - query options overview<https://learn.microsoft.com/odata/concepts/queryoptions-overview>"}