Power Apps - Query String Parameter
Technical article about Power Apps - Query String Parameter
Technical article about Power Apps - Query String Parameter
Let’s learn how can we passing parameter to our Canvas Apps.
In this Example, I built a simple app to write a ticket in SharePoint List. In this case , I need to pass (from “external”) a parameter to our App, to set Ticket Type. My choose are:
To achievement this, we should use “Query String” and Param Function. Query String is part of url , used to passing data to application.
To get query string, I used param function in OnVisible event of my Screen to get date and store it on local variable. I can’t use “On Start” event of app because UpdateContext is only available while you are currently on a screen. When the OnStart code is executed no screen has loaded yet.
Code to copy:
If( Param(“TicketType”) <> Blank(), UpdateContext({selectedTicketType: Param(“TicketType”)}), UpdateContext({selectedTicketType: “Infrastructure”}) );
In my Example, I used a Form with SharePooint list as Datasource . My field “Ticket Type” is Choose field. To set value as default, I set Default property of datacard, only if the form is in “insert mode”. Why? because if we are in view or in edit, we need to see data of item, not our parameter. So:
Code to copy:
If( frmCreateTicket.Mode = FormMode.New, { ‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”, Id: 0, Value: selectedTicketType }, ThisItem.TicketType )
You should call your app with query string, in my case:
https://apps.powerapps.com/play/xxx-xxx-xxx-xxx?tenantId=xxxx-xxx-xxx-xxxx**&TicketType=Services**
(xxxx are guid of your app and tenant id, you see it when you run an app in browser)
Have a nice day!