Teams published PowerApps can be added very easily to the team either when provisioning new teams and using Team Templates or by simply adding a new tab manually. Just choose the Power App and add it as a tab to the channel in question. That will either add the application or make it possible to initiate the app installation to the team.

When adding a Dataverse for Teams Power App to a team you must remember to configure permissions to the application and to the data so that everyone in the team can use it. When adding the app during the new team provisioning this often means that these applications are shared to everyone in the organization.

Adding a parameter to the application

There isn’t a pure custom parameter you can add to Power Apps. But there are parameters that can be defined and passed to the Power App in team tab when the tab is added. This means you can reuse an unused parameter to pass along your own data to the application – thus making it possible to fine-tune it to the team.

Of course you can create your application in a different way, so you don’t have to pass along a parameter: The application knows it’s team and channel where it had been installed, and could retrieve required parameters from a central storage (Dataverse table, Azure, SharePoint list, and so on).

In this blog post I focus on reusing subEntityId parameter.

That parameter can be found in the Context variables list. Most of those values have been prefilled by Teams, but subEntityId seems to be on reserve. So using this trick works for now. It is easy to retrieve those variable values in Power App using the Param-function, like in the picture Param(“subEntityId”). These variables are set when the application is called from Teams and it has Teams context (Dataverse for Teams).

Add application to the team

At this point you should have already the manifest file ready to add the application to Teams organization app catalogue. That is the prerequisite before you can add this application to the team using Graph API. Go ahead and add the application to the organization catalogue.

Important: notice that the application id inside the manifest is not the same as the application id in your application’s manifest.

To retrieve the app catalogue application id, you need to either open the application in TAC (Teams Admin Center) and look it up from there, or use some Graph API to retrieve it.

GET https://graph.microsoft.com/v1.0/appCatalogs/teamsApps?$filter=distributionMethod eq 'organization'

Once you have both IDs you can go ahead and add the application to the team.

POST https://graph.microsoft.com/v1.0/teams/{teamid}/installedApps
application/json
{
   "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{applicationIDinAppCatalogue)"
}

Now that you have the application added to the team, you can go ahead and add it as an tab. This is not the officially supported way, but I reverse engineered the required payload json by checking what’s in existing tab using Graph Explorer.

The easiest way to do is, is to follow the example. Add the application to a single team (with less tabs) and retrieve the payload json using Graph Explorer.

GET https://graph.microsoft.com/v1.0/teams/{teamid}/channels/{channelid}/tabs

You will get some extra information there, but they key thing is that you can retrieve

  • teamsApp@odata.bind (this you can create from applications ids as well)
  • webUrl
  • entityId (this is the external application id – which is application id from manifest)
  • contentUrl
  • webSiteUrl

Then you do a slight tweak to contentUrl.

Find out where &subEntityID= is there and give it a value. In PowerShell I used a variable I was able to add there.

Now you can get your Post call ready

POST https://graph.microsoft.com/v1.0/teams/{teamid}/channels/{channelid}/tabs
application/json
  {
            "id": "MyTab1",
            "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{applicationIDinAppCatalogue)",
            "displayName": "Graph Power Demo",
            "webUrl": "Fill this one from Graph Explorer results",
            "configuration": {
                "entityId": "{externalID}",
                "contentUrl": "Fill this one from Graph Explorer results but change subEntityId value. https://apps.powerapps.com/play/ ... }&subEntityId=Enterprise 1701&teamId= ..",
                "removeUrl": null,
                "websiteUrl": "Fill this one from Graph Explorer results"
            }
}

Keep in mind External ID is the ID from the manifest.
Looking at the result, I can now display the subEntityID value in my demo application. Of course in the real world you would use that information to more useful, like a customer or project identification to make Power App to display relevant information.

Utilizing this can be used in the customized provisioning process that adds Dataverse for Teams applications to team – with custom information relayed to the app.

To summarize

  1. Create your Power App and place into it logic that benefits from data passed in via subEntityID
  2. Make sure you have given permissions to the both Dataverse for Teams Power App and to it’s data sources
  3. Publish the application to the organization catalogue
  4. Retrieve both IDs for the application
  5. Add application to the team during provisioning or when rolling it out to existing teams
  6. And add the application to the team channel as a tab, with customized valued in subEntityId
Previous articleMigrating your Hashnode blog to a new domain
Next articleMicrosoft Ignite 2021: My Schedule, 10 for Teams and Everything Else I’d Recommend
avatar
MVP for Office Apps & Services (Teams & Collaboration focus), Principal Consultant in Office 365 and Modern Work. Extremely passionate about Microsoft Teams's power to change how people work together. Helping and coaching customers to find benefits, solutions and value when adopting new tools, methods, ways or working and practices into daily work-life equation. I am always eager to challenge current situation and dig out new possibilities and ways to think and work. You could describe me as a jack of all trades but my main focus area and deep personal driver is Microsoft Teams since it has changed the way I work and did a giant step forward to make it possible to work from anywhere - the location does not matter even us much as it mattered before. Microsoft Teams opened the path for many organizations to rethink their practices, worklife, culture and start the change. That's why I am very passionate about Teams.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.