cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FacundoGorla
Resolver II
Resolver II

How to get the last created events of my calendar?

Hi! I'm using a powerapp to manage meetings rooms.


I need to be able to get the LAST created outlook meetings of my calendar and collect them. This is what I'm using but for some reason it doesn't prioritize the last created ones therefore when there's too many of them the last created ones are being left out when I want the exact opposite to happen. This is the code to get them:

 

ClearCollect(
        MyCalendarEvents;
        Sort(
        Office365Outlook.GetEventsCalendarViewV3(
        
            MyCalendar;
            Text(
                 _minDate;
                UTC
            );
            Text(
                _maxDate;
                UTC
            );{'$orderby': "createdDateTime"}
        ).value
    ; createdDateTime;Descending))

 

I though that by using 'orderby' my problem would've be solved. Is the first time I'm using Odata so I may be doing it wrong. 
Please save me 😁

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for your reply!

The min Date is set for 2020-01-05 and the max Date is a year from today.
I tried your formula, actually that was the one I used originally until I realize it wasn't getting all the events.

 

I did a CountRow for MyLastCalendarEvents and the result is 256. I never knew about this limit, is it impossible to get more than 256 events from a calendar with this function?

I know there's more than 256 meetings in that time frame. And the biggest problem is that it doesn't get the last created ones first. therefore leaving the most recent ones out of the system.

Update: I use '$top' in the function and set it to 500 or 2000 and now there's 409 events. And I think there's no one missing. So it seems that by default it only gets 256? on the official documentation it says that if you don't use $top it would get ALL the events but doesn't seems like it.

View solution in original post

4 REPLIES 4
v-siky-msft
Community Support
Community Support

Hi @FacundoGorla ,

Since the Start and End dates are all in UTC time zone, please ensure the latest event in the calendar you want is within that time period, notice the difference in time zone.

Beside that, I found the orderby query doesn't work on DateTime Field, but it works fine on other fields, such as the Subject field. I suggest you give up using this orderby query although I'm really confused with this.

I would suggest you set the maxdate to large enough, and try with the following code to see if the last event show in the collection.

ClearCollect(
        MyLastCalendarEvents;
        First(Sort(
        Office365Outlook.GetEventsCalendarViewV3(
            MyCalendar;
            Text(
                 _minDate;
                UTC
            );
            Text(
                _maxDate;
                UTC
            )
        ).value
    ; createdDateTime;Descending)))

If this still doesn't work, How many events do you have in this time period? Can Office365Outlook.GetEventsCalendarViewV3() function get all events?

Hope this helps

Sik

Thanks for your reply!

The min Date is set for 2020-01-05 and the max Date is a year from today.
I tried your formula, actually that was the one I used originally until I realize it wasn't getting all the events.

 

I did a CountRow for MyLastCalendarEvents and the result is 256. I never knew about this limit, is it impossible to get more than 256 events from a calendar with this function?

I know there's more than 256 meetings in that time frame. And the biggest problem is that it doesn't get the last created ones first. therefore leaving the most recent ones out of the system.

Update: I use '$top' in the function and set it to 500 or 2000 and now there's 409 events. And I think there's no one missing. So it seems that by default it only gets 256? on the official documentation it says that if you don't use $top it would get ALL the events but doesn't seems like it.

View solution in original post

Hi @FacundoGorla ,

 

I think the Document has fooled us, I also thought the default top is all.

Does your issue been fixed when you set the Top to 500/2000? If so, please accept the answer as the solution to help other members find it quickly.

Sik

I have 410 events and it does get them all. 
But I'm afraid it still won't prioritize the last created ones and if I hit the next limit (500 or 2000) I'll encounter the same issue. 
If someone with more events than myself would try to do this the $top solution won't be enough, for now it works for me.

Thanks for the help, I'll mark the solution.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (57,123)