Hey, I have built a basic Case Management Canvas App using Dataverse for Teams. The app is published to a tab in a Teams Channel.
When the user opens the app, they start on a landing page with a Gallery listing the cases they have access too. From here, they can either click to open an existing Case or hit a New Case button to create a new Case. The Case form includes a user lookup to select a Team Leader.
The app is supported by a Power Automate flow that is triggered by the creation of a new Case. This sends an email to the selected Team Leader, telling them that a new Case has been created. The email includes a button that takes the user into Teams and opens the app at the correct Case. This is done via a Deep Link, using the subEntityId context variable. I have some code on the OnStart event of the app that checks for a value in this variable and navigates the user if it exists.
My OnStart code uses the basic approach of .... If( !IsBlank(Param("subEntityId")), do something .... and uses the subEntityId to find the associated record / set other variables etc.
Up to this point, everything is working as expected!
Now comes my issue ... the app inside Teams seems to remember the URL and context variable value. So if the user navigates away from the app, browses some other teams, chats with colleagues etc., then navigates back to the app, it reloads the same Case from the email link they originally selected. The subEntityId holds the value even though the user closed and reopened the app.
The user has to actually Quit Teams completely before it looses the subEntityId value.
I have done some research and it seems that I can't clear subEntityId from within the app. I found some workarounds by using Launch() to reopen and close a fresh instance but this isn't an ideal approach, nor does it work for apps built inside Teams.
I have also tried setting a variable with the value of the subEntityId, and using this to navigate to the case as I can clear the value once the user closes the Case.
I'm kinda stuck in a loop. The subEntityId is always there and so every time the app loads, it navigates the user.
Does anyone have any thoughts on how best to approach this? Any help would be much appreciated!
Luke