Vanderwood
Vanderwood

Reputation: 193

Logic App Using Filter Query in Get Entities Action

I am new to logic app and try to build and logic app to check the records in Azure table. The PartitionKey is a string type of DateTime.utcNow().Ticks. I want to write a filter query to filter the records whose PartitionKey is less than or equals to current DateTime. My effort is shown in the screenshot:

enter image description here

It keeps telling me the expression is invalid. Can anyone give me some hints to write the correct query for my purpose? Many thanks. I am not sure why this expression is invalid.

Upvotes: 0

Views: 9204

Answers (2)

Vanderwood
Vanderwood

Reputation: 193

Thanks for George's hint, I just need to add single quote rather than using the string(). This will help me convert the ticks value to string so that I can compare it with the PartitionKey field. enter image description here

In this way, it performs the same as this table query for me:

string currentDateTime = DateTime.UtcNow.Ticks.ToString();
TableQuery<EmailTableEntity> rangeQuery =
                                new TableQuery<EmailTableEntity>()
                                .Where(TableQuery.GenerateFilterCondition
                                ("PartitionKey", QueryComparisons.LessThanOrEqual, currentDateTime));

Upvotes: 1

George Chen
George Chen

Reputation: 14324

Firstly your filter query expression, the format should be Timestamp le datetime'2019-03-18T06:07Z'.

Second the expression doesn't need the ticks function, if use it the query expression will be like the below pic hows.

enter image description here

So actually the right query expression should be Timestamp le datetime '@{utcNow()}', if you get the warning, go the code view mode change the expression and don't forget the single quote.

enter image description here

enter image description here

And here is my test result, hope this could help you, if you still have other problem please feel free to let me know.

enter image description here

Upvotes: 3

Related Questions