web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Find the Defaul...
Power Apps
Unanswered

How to Find the Default Calendar of the user without user selecting them from dropdown

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Community,

I have an app where onselect i have create event action. CalendarPostItem. However the user from mexico gets the error while performing the action since the Calendar name is different in his outlook. Is there a way to get the default calendar name without user selecting from the drop which is not intuitive. How to get the default calendar of a user automatically.

User getting the error

PowerO365Guy_0-1618613439666.png

 

The code i have it

PowerO365Guy_1-1618613474000.png

 

Categories:
  • RusselThomas Profile Picture
    4,014 on at

    Hi @Anonymous ,

    I'm guessing that it's an Exchange server language difference, as the default folder names are created based on the language of the server and the client can display them differently based on the language of Outlook.  From an API call perspective, you're talking to the server, so the client language should be irrelevant.

     

    Looking at the construct of the connector and even a quick run through the Outlook Mail endpoint in the Graph API doesn't reveal any obvious way to determine "default" calendar - so I'm guessing as Outlook connects to all calendars, ("Calendar", "Birthdays", and any other custom calendars) the 'default' calendar is just a 'View' that is configured client side.  If so, then I doubt there's a way to determine that by interrogating the Outlook service. 

     

    However, as it may just be a language disparity, it should be easy enough to gather and cater for all relevant language versions of the default "Calendar" folder that is created when the mailbox is created? 

    For example, if it's Spanish it would be "Calendario" (or something - I don't have a server with a different language to refer to) - but whatever it is, it should be the same term for all Spanish language mailboxes. 

    As such, it shouldn't be too much of an issue to just create a table of the most commonly used terms and check against it.

     

    Granted, this might not be a perfect solution - users can create custom calendars and can even call them by the same name as their original calendar - they are only distinguishable by their GUID's - but as you were relying on the name field for your lookup anyway this shouldn't be any less reliable than your current approach.

     

    If you really want to, you can set up a flow with a powershell function to get the users mailbox language (Get-MailboxRegionalConfiguration) and then use the relevant term based on that - but that's a lot of effort and security privilege use for something that can be a lot easier if 'hardcoded'.

     

    As there is a finite list of Exchange supported languages (about 11 for Server, and about 122 for client) then it's probably just easier to hard code a list of terms (one for each language) and use those references.

    By the way - I generally find

    LookUp( Office365Outlook.CalendarGetTablesV2().value, name="Calendar").name

    to be redundant when you actually know the name of the Calendar.  You're asking for the name field of the calendar where the name = "Calendar".  If you know the name field already, you can just use the string "Calendar" here (or "Calendario" as the case may be) and save yourself the extra call to Outlook.  This is handy for reducing expression complexity, multiple calls to Outlook or passing in strings that come from variables or lookups.

     

    We still want at least one call to get the outlook calendar table reference, so we can cycle through the calendars and compare against our language list to find the one we want - but we only have to do this once to get the correct term - after that we can just pass the term into each postEvent call as a string.  You could, for example, do this on your app start.

     

    By way of example, try creating a lookup table with various terms for "Calendar", including "Calendar";

    ClearCollect(collectCalendarReferences, 
     {calendarName: "Calendar"},
     {calendarName: "Calendario"} // and so on - make as many as you like 
    )

    Then, just cycle through the users calendars to see where there's a match and return that match.

    Clear(collectNameResult);
    ForAll(Office365Outlook.CalendarGetTablesV2().value, 
     If(
     ThisRecord.name in collectCalendarReferences.calendarName,
     Collect(collectNameResult, ThisRecord.name)
     )
    )

    Because we're inside a ForAll() we can can't use Set() or UpdateContext(), so instead we just clear a collection before we run it, (for edit-mode testing inside app-start, or if it's outside of your app start) and just collect a single row with our resulting matched calendar name.

    Then, whenever you use your postEvent function you can pass in the stored value;

    Office365Outlook.V4CalendarPostItem(
     First(collectNameResult).Value, //our matched calendar name
     "Subject", //and you know the rest....
     startDateTime, 
     endDateTime, 
     Timezone 
    )

    Hope this helps,

    RT

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RusselThomas  Thank you so much for a detailed explanation and suggested workaround.

    I would try to replicate and let you know the outcome.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Russel,

    Unfortunately this didn't work either. Its very strange. The user's calendar get tables shows the calendar name as "Calendario" but if i use a predefined collection of localized name and lookup as you suggested the variable came with the output   Calendario. 

    However using that variable in creating the Meeting in PowerApps Failed to work. If i manually specify the Calendar name as  "Calendar" it works for him.

    Not sure why the internal calendar name is Calendario but doesn't with V4CalendarPostItem doesnot work. even for deleting the event it doesn't work. Now my worry is will "Calendar" work for all users. its so inconsistent. 

     

    PowerO365Guy_0-1619031005734.png

     

  • RusselThomas Profile Picture
    4,014 on at

    Hi @Anonymous ,

    It may be the difference between client and server regionalisation - like some timezone offsets, it may be that the connector has some methods that convert for localised region and others that don't...

    For example, reading calendar method might need to convert for local language to identify the right calendar, but posting events might use server designation of calendar because the server doesn't do the converting - to be honest, I simply don't know.  But I agree, without really understanding what's going on under the hood, it does appear inconsistent.  @v-bofeng-msft any ideas here?

     

    Kind regards,

    RT

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RusselThomas  The internal name is Calandario as per mailboxfolderstatistics output also in PowerApps using the Office365Outlook.CalendarGetTablesV2().value shows the name as Calandario. 

    ezgif.com-gif-maker.png

     

    But CalendarPostItem, DeleteItem, GetEvents  Office365Outlook funtions doesn't work with internal name, when given the calendar name as  "Calendar" only works, so I am not sure which would be the ideal way to have it worked for any users. we have users across globe but skeptical if it will work if given as "Calendar" for all. How to make it work for all.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Community,

    Any Idea or recommendation or Suggestion ?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    How about using the id instead of the name? 

    ForAll(Office365Outlook.CalendarGetTablesV2().value, 
     If(
     ThisRecord.name in collectCalendarReferences.calendarName,
     Collect(collectNameResult, ThisRecord.id)
     )

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard