Power Apps Deep Linking to Screen | App StartScreen & OnStart

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone reza here in this video i will show you how to perform deep linking in power apps there is a new function for the app object called start screen where we can define which screen and the power app we would like to start with when the power app launches and for that we can leverage query string parameters that we can pass when we launch our power app i will cover deep linking with security concepts multiple parameters and also show you how we can restart the power app especially where the app is being leveraged through the mobile device so let's get started with the video [Music] i have an event itinerary powerapp which allows the users to organize all the important event details all in one place this power app has multiple screens the landing screen for the power app is always the first screen that is placed in the screen's tree view i can move screens up and down using the ellipses option to move the screens in the screen view when a user launches the power app the first screen that will show up would be the first screen that's listed in the screen view however there are various scenarios in which you would want to perform deep linking into specific screens for example we would like to provide the users a link that directly takes them to the list events screen or if the user is the administrator of the system they should directly be deep linked into the administration screen when they launch the power app now to perform deep linking in the app object we have our function called onstart and this is the first function that gets called when the app is launched and we widely use this for initializing our global variables or prefetching some data into collections we also determine which screen should be shown first let's say in this scenario i would like to navigate the user to the list event screen however when i write a navigate function in the onstart property of the app object i get this message that says navigate is not supported in onstart use the start screen property instead for better performance app onstart function is imperative in nature it is an ordered list of work that needs to be done before the user is directed to the first screen and typically that screen is the first screen that is listed out in the screen view but in case i put a navigate function in here first all of these actions have to complete then it will get to the navigate function it limits the optimization and performance capabilities of power apps so instead of navigating to screens in the onstart function the recommendation now is to use a new property for the app object called start screen and here i can define the screen with which the app should begin with if this is left empty in that case it will pick the first screen in the screen's tree view if i have a screen reference provided here for example list events screen then if this app was to be launched it would directly start with the list event screen we can even test this out in the edit mode of the power app by right clicking on the app object and we have a new feature here called navigate to start screen so if i select this it will redirect me to the starting screen which now is the list event screen now with this setup and play if i was to save and publish my power app and if i was to launch this power app this time it will redirect me to the start screen that was specified so app.startscreen is the new declarative way to indicate which screen should be shown first and that in turn doesn't block any performance optimizations for the power app let's try and perform deep linking into specific screens depending upon query parameters that we can pass to our power apps when we launch our app this can be extremely handy in a wide variety of scenarios for example a new event is created the user gets notified the user clicks on the link in the email and it directly takes the user to that specific event that was created or provide a link to the user to create an event or if the user is an administrator of the system they should be directed to the admin screen so basically my start screen cannot be hard coded it needs to be conditional it needs to be dynamic and to do that i can pass query string parameters here i will write a condition to read the value of my query string parameter i can define the name for that parameter i will leverage the switch function the value i will leverage the function param the parameter that i would be passing i will call it screen name if that value let's say is events in that case i would like to set the start screen to list events screen if that value is admin i would like to start with the admin screen if that value is event i would like to redirect the user to my event screen and if none of the switch cases are met in that case i would like to set the start screen as the welcome screen this is what the completed formula looks like in my case now to test this out i have to pass a parameter to my power app and for that i would have to save and publish my power app my parameter name is called screen name please bear in mind these are case sensitive so when we are passing these parameters to power apps it has to match the case that's defined here now for my event itinerary powerapp if i head over to details here is the web link to play my power app and if i select this it will launch my power app and start with my start screen which is my welcome screen however here i would like to pass a parameter to it so it directly deep links into a specific screen in the url i have a question mark meaning there are parameters that will be passed after this one of the parameters here is tenant id right after this i would like to pass another parameter so i'll use ampersand my parameter which is called screen name and then i can define a value equal to events now when i pass the parameter events this time when the app launched it redirected me to the events screen if i pass that parameter as admin it directly deep links into the admin screen and if i pass event it will deep link directly to the event screen which is my form screen for the user to create a new event remember these are case sensitive so if i was to change the name of my parameter in that case it will not perform the deep linking action same thing goes for the value the events that are listed out on the event screen i can select an existing event and it will redirect me to the form screen wherein the mode of the form is edit meaning the user can make changes to that specific item i have done multiple videos on reusing the form control and the concept that i recommend to use is when the user selects an item in the gallery we set the mode of the form to edit we then set a variable to the current item of the gallery and then navigate the user to the form screen so when i head over to the form screen the form control has a property called item that i am setting to that same variable which is var item and when the user clicks on the plus icon to create a new item i am resetting the form so it goes back to its default mode which in my case for the form is set to new and then i navigate the user to the form screen where the form control now is in new mode and the key here is in the default mode property wherein i start with a new form experience now when we are deep linking into a screen and specifically a screen that has a form control experience we would like to direct the user to form screen to showcase a specific record that means open up an existing item in edit mode now for that i need this variable which is where item to be set now i have multiple parameters one that tells me to redirect the user to the form screen and second that tells me which item i need to showcase in edit mode now the start screen function only and only expects screen related values you are not allowed to enter any functions here i will leverage the onstart function i will use an if condition to check if my second parameter that i would be passing which would be called id if this is not blank in that case i would like to set that variable which is where item to the context of the item my events are being stored in a sharepoint list and sharepoint has the id column which is the unique identity of that item that i will pass as a parameter to my powerapp once i get that parameter all i have to do here is look up that item from my sharepoint list which is event itinerary that is connected in my powerapp and my condition here is id equal to pattern id i'll close the lookup function i'll close the set function i'll close the if condition and i will click format text there is a warning of incompatible types that's because the param function always returns data in the form of string however id is a number so to convert this to a number i will typecast this with value the screen name parameter is event it will redirect the user to the event screen however the mode of my form by default is new i need to set that to edit and that action as well i will take in the onstart function right after i set the item i will use the function edit form and provide the name of my form now that i've made my changes i will save and publish my power app let's take an example of the event with the id 18. when i call my powerapp i will pass an additional attribute here called id equal to 18. this time when the powerapp launches it will redirect me to the event screen but because i also got an id parameter i was able to look up that item and also set the mode of the form to edit if i do not pass this parameter it will open that same screen but in new mode let's take the admin screen for example now these query string parameters can easily be manipulated by any user i have a user sarah who is not supposed to access this admin screen but if sarah was to fire that url sarah was able to access that admin screen now to add some security logic wherein you would like to set the start screen for the user only if they match specific permissions and these could come in any form the user has created that item or not is the user in a sharepoint group in an ad group in a microsoft 365 group i have done videos where you can check the security of the logged in user in this case i'll keep it extremely simple let's say i would like to define my administrators in the power app itself now for the start screen property in the switch function if the screen name is admin i am setting the start screen to admin screen so let's add a check right here if the current logged in user and i can get their email address using user.email if this is in an array that i define and these are my administrators that i would like to define in the app here i'm just defining a single admin which is brezza so i've provided reza's email address so if this is true take them to the admin screen else take the user to the welcome screen and i will close my if condition once again i'll save and publish my power app i will try and run the app with reza's account reza is an admin so when that parameter was passed reza got redirected to the admin screen whereas i can see all the events created by all the users when sarah now tries to open the app with that parameter sara does not get redirected to the admin screen in fact the start screen here is the welcome screen and there is no way for sarah to get to the administration screen so sarah can only see the events that she has created so let's create a flow that sends a notification to the admin when a new event is created in the system i'll create an automated cloud flow i'll pick when an item is created trigger connect to my sharepoint site connect to my sharepoint list and here i will use send an email v2 action i will send the email to the admin which is reza the subject of the email i will use an emoji here new event created and i'll plug in the title of the event in the body of the email since i would like to provide links to the user to directly launch the power app i will switch here to code view here i can add dynamic content for example the title of the event this is plain html i'll put a line break maybe give the type of the event and so and so forth i would like to give a link to the user to open that specific event in the powerapp and for that i will leverage the anchor tag where the href is what i will need to specify for my event itinerary powerapp i have this web link that i can copy and paste it right here in between single quotes to this i would like to pass my parameters my screen name parameter which will be event and the id parameter which i would pass by leveraging the dynamic content i can close my anchor tag i will call it open event and i will close my anchor tag let's try and add another anchor tag which i have called admin view the screen name parameter that i'm passing here is admin and for the third link that i've created called create new event all i'm passing is the screen name event i'll go ahead and save this flow let's test this flow out i'll create a new event i'll fill the event form and click submit and here is the new event that has got created now this flow is listening to any new item that gets created in the events list and the flow has triggered for the item i just created if i head over to my email here is the email that i have received new event created here is the name of the event and in the body of the email i have those links if i select open event it will launch the power app pass those query parameters screen name and id and it will directly deep link into that specific screen in my power app if i pick admin view it will launch the power app and deep link into the admin screen and if i pick create new event it will launch the power app and direct to the event form screen in new mode now currently i am launching the power app directly from my web browser experience however from the mobile device experience be it mobile or tablet if the app is already open and if i try to click on the link in the email again it will not restart the app and that is a challenge because if the app is already running in the background and if i click on a link that i receive in an email or a push notification it will not perform the necessary deep linking action and the simple fix to take that step is as follows we need to pass another parameter which is restart app equal to true this is case sensitive again i will do that for all my three links this same deep linking experience we can also take the advantage of the powerapps push notification feature once again i've done a video on this the link will be in the description my mobile app will be powerapps my app is event itinerary the recipients i will simply plug in the email address of the users who need to receive this push notification in this case i'm just sending it out to reza the message will be as follows open the app will be yes and parameters here i will be passing an object of key value pairs my first param is my screen name which is event my second parameter is id the value will come from dynamic content and the third parameter is restart app true so that it initiates a restart of the app specifically for mobile devices i will save my flow this time let's say sarah creates a new event and clicks submit the new event has been created my mobile device is being projected here is the email that i received if i click on open event it launches powerapp and takes me directly to that specific screen deep linking an action here and this is the event that sarah created now this app i will keep it open it's still running in the background this time if i click on a different link let's say the admin link notice how it restarts the app and it takes me directly to the admin screen let's try the create new event link again it will restart the power app and take me there and this is purely because of that extra parameter that i passed which was restart app true also i received that push notification if i select that push notification again it restarted my app and deep linked me directly into my event screen with that specific item opened and these same deep linking concepts i have leveraged in a wide variety of different scenarios here i have a leave request power app wherein users can create a new request i'll put in my leave request in the system the request gets created and it has gone to my manager for approval which is sarah sarah gets the approval email notification from flow and here the link that i have provided is a link to my power app once again deep linking an action i am passing the id of the item which i am leveraging to redirect or deep link the user straight to my request screen i have also leveraged this to create connected web part scenarios in sharepoint with power apps here i have a sharepoint list and on the right hand side i have an embedded power app when i select a specific item these are connected web parts i pass the id of the item and i'm deep linking directly to my screen that shows that specific item in my power app this one is a standalone powerapp this can also be achieved with a sharepoint list form customized powerapp utilizing that same deep linking experience if you enjoyed this video then do like comment and subscribe to my youtube channel and thank you so much for watching
Info
Channel: Reza Dorrani
Views: 44,585
Rating: undefined out of 5
Keywords: powerapps deep linking, powerapps deep linking to screen, powerapps deep linking email, deep links, deep linking, powerapps, power apps, deep linking powerapps, power apps link to item, power apps deep link to form, powerapps param function, powerapps deeplink, powerapps url parameters, powerapps query string, microsoft powerapps, powerapps tutorial, powerapps deep linking video, reza dorrani, powerapps startscreen, powerapps deep link to specific screen, startscreen, learn
Id: Hrc51S2NgBo
Channel Id: undefined
Length: 22min 56sec (1376 seconds)
Published: Mon Aug 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.