Working with Query Parameters in Power Apps

  • Introduction
  • Scenario
  • Implementation
  • Nurse View Link
  • Admin View Link :
  • Consume the Parameter in PowerApp
  • Adding the Query Parameter Links to SharePoint
  • Test the Audience Targeting and View Change

 

Introduction

Passing of Query Parameters in URL is something we used to leverage most often when we wanted to pass an input parameter to an application URL so that we can extract the parameter and process the application based on the passed Input. This makes the application more dynamic and helps prevent the duplication of the application to cater multiple audience. The application can still contain the logic for multiple audience and based on the query parameter that identifies the targeted audience using it, we can show the needed side of the application and intentionally abstract or hide the rest of the application from the current user.

Similarly in Power Apps, most often, we have to set the start screen or show specific screens based on the users using it. In this article we will see how to Pass Query parameters to Power App from a Web Application like SharePoint and show the start screen based on the Query parameter.

Scenario

We have created a Medicine Inventory App that is used by Nurses to keep track of Incoming and Outgoing Medicines. It has 2 screens:

  • Nurse View – That provides the nurses with the incoming and outgoing stock modification options

  • Admin View : That provides a super admin with the report generation and analytics viewing option in addition to the default incoming/outgoing stock update buttons.

We will see how to Provide the Link to the Power App in SharePoint Page in such a way that Nurses will be able to see only the Nurse Link on the SharePoint page and the Admins will see only the Admin Link. Clicking on it would open the Power App with their respective screens.

Implementation

To get the Weblink to the created Power App, we can go to the details page of the app

Select the WebLink URL which we will be using to create the link with appended Query parameters.

 

We will create two links by appending the query parameter named View and assigning Nurse and Admin as the respective values in the link

https://apps.powerapps.com/play/4002208c-8de3-41a4-b29b-774d69378fb8?tenantId=b3629ed1-3361-4ec4-a2b7-5066a5c5f?View=Nurse

https://apps.powerapps.com/play/4002208c-8de3-41a4-b29b-774d69378fb8?tenantId=b3629ed1-3361-4ec4-a2b7-5066a5c5f?View=Admin

Consume the Parameter in PowerApp

We will now see how to extract the Query parameter named “View” inside the Power App and switch the screen based on its value.

Power App has a Start Screen Property for the App where we will specify the below expression that reads the Query parameter using the Param function and based on the value, we will set the start screen

If(Param("View")= "Admin",Screen_AdminView,Screen_NurseView)

Here the expression checks the query parameter named View and if its value is Admin, it sets the Admin Screen as start screen else it sets the Nurse Screen as start screen.

 

Now, let’s see how to set the Nurse and Admin Links in SharePoint and Audience Targeting for the links so that the Links will be visible to Nurses or Admin based on their existence in a AD Security group. This was we can ensure that Nurses don’t see Admin Link and thereby not giving them unintentional access to the admin view.

As the first step, lets edit the SharePoint page where we want to add the links and add a Quick Links Webpart. We will also add the links to both Nurse and Admin View.

 

As we can see above, we have not updated the Audience to target section. Let’s create 2 Security Groups in Azure AD for Nurse and Admin and update the Audience Target sections as well

Let’s head back to the Quick Links webpart and update the both the links with the respective groups so that only members of that SharePoint group will be able to see the corresponding links. We will add the Nurse Security group against the Nurse View Link

Same way for Admin Link, we will audience target it to the recently created Admin Security Group

Summary

Thus we saw how to Audience Target Power Apps using Security Groups ,  Pass Query parameters via weblink and switch start screen based on the Query parameter.