Filter Query with {VersionNumber}

The SharePoint Get Items action in Power Automate is very useful. One of the configuration options is the usage of the Filter Query field. In this article I will show you how to filter on the {VersionNumber} in this action in a Power Automate flow.

Inspiration

This question from angelsansev:

I’m trying get files with the {VersionNumber} greater than 5 for example.

the odata filter always show error “Creating query failed.”, the VersionNumber property has a special characters “{” and “}”.

I have try with _x007bVersionNumber_x007d_ but dont work.

Power Users Community thread: Problem to filter by VersionNumber.

Creating query failed error

Normally it is pretty straightforward to create OData Filter queries in a SharePoint connector Get Items action. You run it once without filtering and just find the internal name of the field in the outputs of your Get Items action and use that in your Filter query with an operator (eq, ne, gt, lt) and a value.

Microsoft has a great doc about this as well, In-depth analysis into Get items and Get files SharePoint actions for flows in Power Automate.

However, in this instance the field {VersionNumber} has curly braces and the OData Filter does not seem to like that.

You would get an error like below.

The $filter expression “{VersionNumber} eq ‘2.0’” is not valid. Creating query failed.

versionnumber_createqueryfailed

Items method

My first attempt was to try and retrieve the items via a Send an HTTP request action. I noticed that there is a field called OData__UIVersionString in the response. It looked familiar because I used that internal field name in the Add a field to a view blog before. Only difference is that is has OData_ in front of it.

versionstringfield

With these type of request you can also use $filter query parameters. The below also worked with that same field.

filterquery_http_versionnumber

OData__UIVersionString

After that I tried to use the OData__UIVersionString in a Get Items Filter Query field. And what do you know, it works! I also tried this filter in a Get Files (properties only) action, in that action it should also work.

filterquery_getitems_versionnumber

Happy testing!

You may also like...

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.