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