Back

BLOG • DIGITAL INSIGHTS

The Autocomplains – Sitefinity OData

Sitefinity's OData Client SDK datasource type does not support the contains filter operator, throwing an \"Unknown operator type\" error. This post shows how to work around it by switching to the standard odata-v4 datasource type and using a custom read function to call the OData service directly.

Sitefinity CMS

Background

Sitefinity 9.0 introduced a new "Content as a Service" API based on the OData 4.0 protocol. This was a significant step forward for developers - until then there was no standard way to expose content via AJAX services on the frontend without writing your own. With Sitefinity 9.0, Progress gave developers the opportunity to focus on business logic and leave more of the boilerplate to the platform.

The Sitefinity team also provided a public client SDK for working with Sitefinity OData services, available from Sitefinity's public NuGet feed. This includes a basic JavaScript API, a new Kendo datasource type called "sitefinity", and documentation.

Of course there will always be limitations and more complex scenarios to handle. In this post I'll walk through one issue we ran into with OData services, its limitations, and the solution we chose.

Assumptions

The Use Case

An intranet portal where an employee can create reports. The report title could match the title of one of their existing tasks. We needed an autocomplete field that would show all tasks belonging to the employee whose title contains a given string.

The Initial Approach - and the Problem

The straightforward solution: a Kendo autocomplete widget with a Kendo datasource of type "sitefinity", using the Sitefinity web services SDK.

HTML

JavaScript

This works great - but only with the startswith operator. As soon as you change the autocomplete's filter property to contains, you get this:

Unknown operator type error when using contains filter

An "Unknown operator type" exception. The contains operator is simply not supported by the Sitefinity datasource type. Not ideal.

The Solution

Instead of using the "sitefinity" datasource type, switch to the standard odata-v4 type and call the service directly. I used a custom read function on the Kendo datasource instance, extracting the input string from the filter object and making the OData request manually.

HTML

JavaScript

Conclusion

Sitefinity OData services and the Client SDK are a solid starting point, but there is still work to be done. Keep in mind that some fairly simple and straightforward tasks can hit unexpected limitations. The approach above also gives you the flexibility to use $expand for navigation properties, add additional filters, and more.

Read More

Explore more insights and case studies from our team.