Why is so useful the Param Function ?

Did you know that you can pass parameters to your Power Apps Canvas using the URL of the app being played? 

Yes, your app can handle and read parameters in query strings! 

You can provide many parameters and customise your app to perform actions based on these values.

Before we look at how you can use this functionality, let’s have a quick introduction of what a query string is.

If you are already familiar with this concept, you can move on.

A query string is the part of a URL that contains data to be passed as input to a program. 

In this particular case, the recipient is the address of a server with the path specified within it to the directory in which the resource to be accessed is located. 

At the end of this address, the character ‘?’ is inserted to delimit the part containing the parameters.

The query string includes two fields: the parameter and its value.

Let’s take an example.

If you search using the google search bar: “Mufasa” you will notice that after clicking enter you will get the following url: https://www.google.com/search?q=Mufasa&hl=it

I have inserted the dots because other parameters will also be present, but already from this portion you can see that we have asked Google to search for Mufasa for the parameter identified by ‘q’.

At this point, the browser interpolates the request by capturing the information in the parameter and returns the list of the best results as a response.

You can also capture parameters with Power Apps.

Power Apps allows us to retrieve parameters in query strings using the function Param() .

Sending parameters in this way will allow your app to react and adapt to the settings when it opens.

Let’s take a real-life example to make things a little clearer.

A very frequent scenario could be the passing of a guid to identify a very specific entity. For example, imagine you have a product catalogue and a detail page for the individual product.

By passing the guid as a query string you could retrieve it and allow the user to go directly to the product detail page.

To better show you how the Param() function works, I created an empty canvas app and added a new label. 

In the “Text” property I inserted a Concatenate with the result of the Param() function. As an argument to the Param function you must enter the name of the parameter you are passing in query string.

This is what it looks like:

At this point I saved and published. Note that in edit mode the Param function cannot read the parameter in query string so you will have to try it with the app in play to test it.

Next I took the url of the app in play and added the guid parameter, see the end of the following url.

Finally, using this new url, I launched the application and obtained the following result

As you can see, the Param() function does all the work necessary to retrieve the information you need.

Clearly the logic to be applied to that parameter should be placed in the onStart property of your application to perform specific actions during application start-up based on the parameters passed.

The concept of passing parameters into the Power Apps URL is extremely simple and can be really useful if used correctly.