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.

{VersionNumber} eq '2.0'

You would get an error like below.

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

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.

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

_api/web/lists/getbytitle('@{variables('ListName')}')/items?$filter=OData__UIVersionString gt '5.0'

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.

OData__UIVersionString gt '5.0'

Happy testing!

Happy SharePoint week!

About the Author

My name is Dennis. I am Dutch and I live and work in the UK as an IT consultant. Currently I work a lot with SharePoint online, Microsoft Teams and all the other products of the Office 365 platform. I also like my share of Dynamics 365 and Azure. I try to blog about everything I come across in my daily job. All the content in my blogs are my personal views and experiences.

Reference

Dennis. 2023, Filter Query with {VersionNumber}, Expiscornovus, Available at: https://www.expiscornovus.com/2023/02/23/filter-query-with-versionnumber/ [Accessed on 4 May 2023]

Share this on...

Rate this Post:

Share: