Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 4NmmapshG7v52Esjan4bSE
Power Automate - Building Flows
Answered

Outlook "Get calendar view of events" order by odata error

Like (5) ShareShare
ReportReport
Posted on 27 Dec 2019 20:09:31 by 78

Hi there,

 

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?

  • Reese1 Profile Picture
    3 on 16 Feb 2024 at 05:12:44
    Re: Outlook "Get calendar view of events" order by odata error

    Four years later and this saved some major hair pulling. What a dumb issue. 

  • JoeGasper Profile Picture
    85 on 30 Jan 2023 at 15:13:11
    Re: Outlook "Get calendar view of events" order by odata error

    Just adding some history, discussions on OData breaking changes about datetime/datetimeoffset.

     

    OData V4 service should support DateTime · Issue #136 · OData/WebApi (github.com)

     

    [ODATA-220] Please consider the restoration of DateTime (without offset) - OASIS Technical Committees Issue Tracker (oasis-open.org)

     

    Seems it took a bit for this spec to trickle into flows.

  • BruceWang Profile Picture
    4 on 01 Dec 2021 at 16:00:41
    Re: Outlook "Get calendar view of events" order by odata error

    The filter and order only support 1 condition like IsAllDay desc only or Start asc only

  • greggdavenport Profile Picture
    55 on 22 Jan 2020 at 23:17:20
    Re: Outlook "Get calendar view of events" order by odata error

    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.

  • jbedfordp Profile Picture
    78 on 09 Jan 2020 at 17:05:48
    Re: Outlook "Get calendar view of events" order by odata error

    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"... 

     

    https://www.odata.org/documentation/odata-version-2-0/uri-conventions/

    (search for "forward slash")

     

    🤕

  • jbedfordp Profile Picture
    78 on 09 Jan 2020 at 16:51:47
    Re: Outlook "Get calendar view of events" order by odata error

    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 ...

  • Community Power Platform Member Profile Picture
    on 09 Jan 2020 at 05:32:34
    Re: Outlook "Get calendar view of events" order by odata error

    @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:

    https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/43

     

    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:

     

    'yyyy-MM-ddThh:mm:ss'

     

    and voila!

     

    Seriously, Microsoft needs to provide a better manual especially how to use OData and its syntax in Power Automate.

     

  • Community Power Platform Member Profile Picture
    on 08 Jan 2020 at 22:17:47
    Re: Outlook "Get calendar view of events" order by odata error

    I see that now! Well lots of thumbs ups to @Anonymous as well. 😁

  • jbedfordp Profile Picture
    78 on 08 Jan 2020 at 22:08:11
    Re: Outlook "Get calendar view of events" order by odata error

    I can't claim credit for this solution at all -- all of my trial and error ended in error! 🤣

     

    @Anonymous 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!

  • Community Power Platform Member Profile Picture
    on 08 Jan 2020 at 21:59:15
    Re: Outlook "Get calendar view of events" order by odata error

    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?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,765 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard