NOTE: As of August 5th, 2020, I've included a segment on Dataflex here which might lead toward WHY this is the case and WHY they may never fix this!
I've done a bunch of testing on this last week just to see if there was some magic formula that I'd missed. And while there are of course some weird workarounds of sending the data to "something else" that then your app reads it out of when it starts, that's a horrible solution. Particularly when Microsoft wants us all to now work all day inside of Teams.
You can, of course, hard-code a parameter when you add a link to a Website and it will work. However, you can't change it at run-time.
NOTE: Dataflex data stores show us a path forward through this. It seems like Microsoft is adjusting how we link items from within Teams and share them w/ PowerApps is changing. I would HOPE that this is one problem that will be addressed, but perhaps not via passing data within the URL.
Detailed instructions on sending in Parameters are here, but I've got the basics below.
Take a PowerApp and get the URL for the application via the PowerApps console | Apps | Details page:
That Web Link allows you to append your own parameters to your application. You can take that URL, append &edit=Y to the end of it in your browser to pass it into your application.
NOTE: it is actually ?1stName=1stValue&2ndName=2ndValue&3rdName=3rdValue, but my environment shows a first item of ?tenantID=... by default which means all of my custom Parameters start with &. Your mileage may vary.
Inside your app, display the value of Param("edit") in a text field and you'll see the value you passed to your app inline.
HOWEVER, if you attempt to use Teams / PowerApps in "the right way" then you embed your PowerApp into a Tab in a Channel in Teams aaaaand all of this won't work.
I've done a bunch of testing on this last week just to see if there was some magic formula that I'd missed. And while there are of course some weird workarounds of sending the data to "something else" that then your app reads it out of when it starts, that's a horrible solution. Particularly when Microsoft wants us all to now work all day inside of Teams.
You can, of course, hard-code a parameter when you add a link to a Website and it will work. However, you can't change it at run-time.
NOTE: Dataflex data stores show us a path forward through this. It seems like Microsoft is adjusting how we link items from within Teams and share them w/ PowerApps is changing. I would HOPE that this is one problem that will be addressed, but perhaps not via passing data within the URL.
The Basics
Detailed instructions on sending in Parameters are here, but I've got the basics below.
Take a PowerApp and get the URL for the application via the PowerApps console | Apps | Details page:
Blacked out for no real reason |
NOTE: it is actually ?1stName=1stValue&2ndName=2ndValue&3rdName=3rdValue, but my environment shows a first item of ?tenantID=... by default which means all of my custom Parameters start with &. Your mileage may vary.
Inside your app, display the value of Param("edit") in a text field and you'll see the value you passed to your app inline.
HOWEVER, if you attempt to use Teams / PowerApps in "the right way" then you embed your PowerApp into a Tab in a Channel in Teams aaaaand all of this won't work.
Two basic ways to embed a PowerApp into a Team Channel
You can create a tab in your Channel and link it to your PowerApp either by selecting "PowerApps" from the Tab creation selection or by selecting "Website".
Your options will vary upon your organization |
Either way, the tab will now take a user who clicks it directly to the application. Easy. Some might say...too easy.
Some people would be right, because now, if you attempt to take the URL from the TAB you will find that the URL is not exactly something that is easily understood. And even if you attempt to understand it (as I spent some time on last week), what you'll ultimately understand is that "you can't get there from here" with regards to parameters.
To test this, I set up two tabs in my Team for one that links directly to the PowerApp and the other to the URL. I used these two tabs to try out an array of variations to test against while comparing the results to the same application except linked directly to the application vs. the Teams tab. In all scenarios, the link to the application directly works, but neither Teams tab works. The Parameter values are always dropped.
So I created the following very simple PowerApp:
The complexity of my app is astounding! |
All it does is shows the value of the "edit" or "Edit" parameter (because I also noticed some curious case changes to the Teams links).
I copied the links from the tabs above:
And I got two strange URLs:
- (PowerApps Tab) https://teams.microsoft.com/l/entity/{a bunch of gobbledygook}?context=%7B%22subEntityId%22%3Anull%2C%22canvasUrl%22%3A%22{an URL-encoded version of the link to my application w/o the tenantId} %3FscreenColor%3Drgba%25280%25252C%252520176%25252C%252520240%25252C%2525201%2529%26source%3Dteamstab%26locale%3D%7Blocale%7D%22%2C%22channelId%22%3A%2219%3{A link to the Channel ID}%40thread.skype%22%7D&groupId={a link to the Team ID}&tenantId={the tenant ID same as my application URL originally}
- (WebSite Tab) https://teams.microsoft.com/l/channel/19%{A link to the Channel ID}%40thread.skype/tab%3A%3A{A link to the Tab ID}?groupId={A link to the Team ID}&tenantId={the tenant ID same as my application URL originally}
The %XY stuff is all URL-encoding. Meaning, they're converting standard "special" characters (e.g. #:=,) into their URL-encoded counterparts. In truth, even the Teams one is much easier to read once you've decoded it. It's just name/value pairs of Parameters that get passed along to the Tab. In fact, one of the first things I tried was to open the PowerApps embedded Tab (i.e. Parameter_Test in my image above) and then click on the "Go to Website" link. I was surprised to see that the screenColor / RGBA() name/value pair (that Teams included for some reason) was included as an inline parameter displayed in the browser window.
So my first (of many) attempts was to encode my example parameter above &edit=Y to be %26edit%3DY (i.e. %26 is actually & and %3D is actually =) and stick it into the middle of the canvasUrl value like this:
- (PowerApps) https://teams.microsoft.com/l/entity/{a bunch of gobbledygook}?context=%7B%22subEntityId%22%3Anull%2C%22canvasUrl%22%3A%22{an URL-encoded version of the link to my application w/o the tenantId} %3FscreenColor%3Drgba%25280%25252C%252520176%25252C%252520240%25252C%2525201%2529%26edit%3DY%26source%3Dteamstab%26locale%3D%7Blocale%7D%22%2C%22channelId%22%3A%2219%3{A link to the Channel ID}%40thread.skype%22%7D&groupId={a link to the Team ID}&tenantId={the tenant ID same as my application URL originally}
To make it easier to read, let's just decode the value of the "canvasUrl" JSON value. After a few iterative decodes it becomes:
- https://apps.powerapps.com/play/providers/Microsoft.PowerApps/apps/{an URL-encoded version of the link to my application w/o the tenantId}?screenColor=rgba(0, 176, 240, 1)&edit=Y&source=teamstab&locale={locale}
That's a properly formatted URL w/ a series of Parameters that now includes:
- screenColor
- edit
- source
- locale
So drop the full original encoded link with my addition into a Teams channel post, click it aaaaand...the application does not retrieve any value for Param("edit").
A second attempt was to of course not encode it and drop it at the end. Since the link is clearly passing values to the Teams interface. The end looks like:
- ...?groupId={A link to the Team ID}&tenantId={the tenant ID same as my application URL originally}
So in theory dropping another value into it like...
- ...?groupId={A link to the Team ID}&edit=Y&tenantId={the tenant ID same as my application URL originally}
...should be passed along. But...no. No dice.
So WTF?! Ooooohhhh...Dataflex (8/5/2020 UPDATE)
So why in the world would you lobotomize the integration (in any way) of your primary custom UI application with your primary UX platform? Dataflex bitches!!!
After talking w/ Microsoft today it is so vary scary how right I was on this one. Uncanny actually. I might be a living breathing Ouiji board or Magic 8 ball.
Microsoft is announcing some terms that they're loosely referring to as "Teams apps" which are apps of various types (of which PowerApps is one of them) that will gain certain features when integrated into Teams. This means, if you build/deploy your PowerApp and connect it to their Dataflex component then (still not 100% but man I'd bet serious money on this) everything will likely work as expected. Meaning that the data you want to pass inline to your application via the URL in the old-school manner outlined above, will be bypassed via some "process status" workflow embedded within a Dataflex component.
As long as you keep your PowerApp inside of the new Teams PowerApp interface (and I believe this will be a distinct environment BY TEAM), then this will likely work.
It's almost like they really REALLY want us to put our data and sweet sweet business rules into the Dataflex/CDS engine for some reason...
Final Thoughts
There are a few UserVoice posts about this being requested as a feature. I honestly am shocked that the original attempt did not work. Teams has to be actively stripping out any non-automatically-generated Parameters from the value of "canvasUrl".
Some might argue that this is some kind of security setting. Of course, if I'm talking about passing a few parameters around then I'm not exactly concerned per the "security" of these values. They're clear/open text soooo. Passing them along to the application seems reasonable since clearly they're passing along their existing values (I did modify the RGBA value on a whim and the change got passed along).
I don't see how anybody would expect me to attempt to embed a real workflow application using PowerApps fully into Teams if I can't pass parameters. In fact, it kind of kills the value of ANY HTTP-based site that might take parameters.
Consider just wanting to edit a SPECIFIC RECORD (e.g. support ticket, etc.). I could give you a traditional URL w/ an ID# appended and Teams would launch the browser and append the value properly. If I embed the same site inside Teams and attempt it, then it will strip anything I append.
Whatever it is that they were thinking regarding this, the simplest use-case results here are just terrible. It really means that you should ONLY embed any application within Teams that you expect to use as a reference and not something truly dynamic.
No comments:
Post a Comment
Because some d-bag is throwing 'bot posts at my blog I've turned on full Moderation. If your comment doesn't show up immediately then that's why.
DIAF Visualpath team