OData and String Comparison Filters in SharePoint

String Comparison Filters

There are multiple string comparison filters for OData/REST in SharePoint. In this article we will explore the following:

    1. startswith
    2. substringof

startswith

This filter returns the field values starting with a specified string.

Please note that the method name is case sensitive and only lower case works.

Example

Please create the data as shown in the following image:

contacts

The following is the query URL.

The following is the result using the Chrome browser.

Chrome browser

Note: Please note that we are querying against the column named Title.

Another Example

Now let us try with a non-existing string.

Here is the query URL.

The following is the result using the Chrome browser that shows no results.

result using Chrome browser

You can now play with more examples.

substringof

This filter returns the field values containing a specified string.

Please note that the method-name is case sensitive and only lower case works.

Example

The following is the query URL.

The following is the result using the Chrome browser.

result

Note: Please note that we are querying against the column named Title. The column name appears second after the value.

More Examples

You can now try a non-existing string.

The following is the URL:

The result is empty XML packet.

empty XML packet

Note: The Open Data Protocol (OData) allows filtering and interoperability on REST services. We combine OData along with REST methods.

So REST + OData allows giving more flexibility in querying and filtering items.

References

Summary

In this article we explored the String comparison filters of OData. In future articles we can test each of them against list items.


Up Next
    Ebook Download
    View all
    Learn
    View all