I created a flow a while back to send me an agenda every evening for my next day's meetings. On 12/18 my flow started to fail with the following error:
The $orderby expression must evaluate to a single value of primitive type.
I noticed that I was using a deprecated "v2" version of the "Get calendar view of events" operation, so I replaced it with v3 but it continued to fail.
My "Order By" ODATA query statement previously was "IsAllDay desc, Start asc", but this no longer works (even when changing the case to be "isAllDay desc, start asc" according to the updated syntax) -- it results in the error above, about which I am not finding much info online.
Incidentally, I tried to add the two columns to the "Filter Query" ODATA query as some articles indicated that may be necessary, but I couldn't seem to get that syntax right, either -- I get "Invalid filter query" no matter what I put, so I'm guessing I'm way off on the syntax.
I was able to get the operation to stop failing by removing the "start asc" part of the Order By (so, leaving only "isAllDay desc"), which is kind of counter-intuitive. I also don't trust that the ordering will actually be correct, though, without enforcing the "start" order as well.
What am I missing here?
Solved! Go to Solution.
Haha! That's a good hack. I had to do something similar to sync a couple of calendars in a different Flow (which has probably also stopped working). I'd really rather not go through all that though. I'm a bit new to these forums - does MS actually read these and note issues, or is there some other mechanism for that?
I am also having the same problem. My flow failed to work because this FilterQuery.
Even the expression 'and' is no longer recognized.
What the hell Microsoft is doing?
Ok. I found the solution.
Here's the examples that will work in the filter query:
Start/DateTime gt '2020-01-08T00:00:00'
If you need to use 'utcNow':
Start/DateTime gt 'utcNow('yyyy-MM-ddT00:00:00')'
Hope this helps!
Fantastic, @jbedfordp! That totally worked. So many thumbs-up button clicks for you. Was this a bunch of trial and error, or did you find something online that explains this behaviour?
I can't claim credit for this solution at all -- all of my trial and error ended in error! 🤣
@BeeBee identified the syntax that works. It appears to cast the "start" field as a "DateTime" type or format?
I'd love to know where this syntax comes from, though! I didn't see this in any of my searching thru ODATA or Flow or Graph API syntax manuals. Wherever this is documented undoubtedly has a bunch of other tips and tricks to offer!
@jbedfordp All thanks to the trial-and-error in your previous post. It's the start of my inspiration.
I was struggling with the Filter Query for utcNow.
Then I found this from github:
At first, I was using:
Start/DateTime gt 'utcNow('yyyy-mm-ddThh:mm:ss')'
and it gets translated to this instead:
Start/DateTime gt '2020-30-08T06:30:57'
so unless we are in different planet, clearly the calendar does not have 30 months.
then I change the date time format to:
Seriously, Microsoft needs to provide a better manual especially how to use OData and its syntax in Power Automate.
Hmm.... but where did the idea for the "/DateTime" syntax come from? That's the bit that I hadn't seen before, and which I think enables ordering by the "start" property. I can't tell if it's OData syntax or Graph syntax or Power Automate syntax or ...
Closest explanation of that I can find is that the "/DateTime" syntax implies that the "start" property has a related (or sub-?) property called "DateTime"...
(search for "forward slash")
Brilliant that you figured this out. This was a life saver for me. I had a Flow that broke within the last month and a half after working for about a year before that because of this syntax change.