Just two weeks ago during MS Ignite Microsoft Teams team has announced Private channels - one of the most asked features.
So, a bit of technical details. Each private channel is a separate SharePoint site collection with a unique site template and no group assigned.
We can discuss a lot if it's good decision or not.
But in this post I want to focus on a specific problem I experienced while developing SPFx solution for MS Teams.
The ProblemYou are developing a SharePoint Framework solution to be served as a Teams Tab. And you want to display some basic team (and maybe group) information in your app.
In general scenario everything looks pretty straightforward: you're getting team context as described here and using groupId property and MS Graph you now can get any information about team or group you want.
But, surprise-surprise! This won't work for Private Channels!
Well, you'll still be able to get the context, but groupId is undefined. Moreover, teamName, teamId, teamSite are actually name, id and site collection url of that private channel. So, there is no any team-related information in team's context.
If you look at web part's pageContext - it's all about private channel's site collection as well...
At that point you can feel really stuck and maybe angry :)
But I have good news for you - there is a solution
The SolutionYou would expect that private channel's site collection somehow "knows" about related team and group...
And that is actually true: there is a RelatedGroupId property in the site collection object as well as in root web's property bag. And it contains the needed groupId value of the related team. So, we can use SharePoint REST API to get that value:
OK, now we can integrate that in our web part:
To check that we can use new team's context property channelType. It is equal to Private for private channels.
One thing about this property is it's not exposed to microsoftTeams.Context interface that is shipped with SPFx v 1.9.1 (the latest one). So, you'll need to do something like teamsContext as any to use it:
Hopefully, I'll save you some time with that post!
That's all for today!