top of page
Foto van schrijverRobert Sep

Get the SharePoint URL for a Teams aware PowerApp

TL;DR : you can use Power Automate to retrieve the SharePoint URL of a Teams aware PowerApp.


Since the first quarter of 2020 it is possible to create Teams aware PowerApps. Teams aware PowerApps have access to the Team's context variables using the Param() function. The value of these context variables depends on the Team a PowerApp is running in, making the PowerApp 'Teams aware', which is especially useful if you publish your PowerApp in the Microsoft Teams catalog.


Although up to 11 context variables (for example groupId, teamId and theme) are shared between Teams and the PowerApp, one of the, in my opinion, most important context variables is missing: the SharePoint URL belonging to the Team the PowerApp is hosted in. A lot of generic app use cases will have some kind scenario in which the retrieval and saving of documents is involved.


Luckily it is easy to retrieve the SharePoint URL using the groupId context variable and a Power Automate Flow.


The above Flow uses the SharePoint search API to retrieve a SharePoint URL (path) using a GroupId as input. The GroupId is provided as a PowerApps function parameter of the Flow.


The search result is returned as XML. I use the following xpath in the 'GetUrl' action to retrieve the URL:

first(xpath(body('Search'),'//*[local-name()="element"][*[local-name()="Key"]="Path"]/*[local-name()="Value"]/text()'))

To make use of this Flow your PowerApp code (for example in the OnStart) should look something like this:

Set(GroupId, Param("groupId")); Set(SiteUrl, GetSharePointSiteUrlByGroupId.Run(GroupId))

You can download the example Power Automate Flow below. Do not forget to change the domain in the 'Site Address' field of the 'Search' action to your own domain.


For a very extended example of using the SharePoint search API in Power Automate see: https://michalguzowski.pl/search-in-sharepoint-from-powerapps/



1.828 weergaven0 opmerkingen

Recente blogposts

Alles weergeven

To Cloud or not to Cloud

De term Cloud, de verkorte versie van Cloud Computing, bestaat al sinds eind jaren 90 en is niet meer weg te denken sinds grote...

Comments


bottom of page