Passing Parameters to a PowerApp
Today I’m going to talk about how and why you would want to pass parameters to use within your PowerApp.
A client has a SharePoint list of employee certifications and their expiration dates. The client wanted to implement a solution where the employee would be notified via e-mail automatically 30 days prior to their certification expiration date to remind them to update their certification. Another requirement was to allow the employee to update only the expiration date of their certification and not any of the other information in that list item. To accomplish this particular piece, we decided to go with a simple PowerApp that has an edit form to that list. We will simply set the controls we don’t want the user to edit to view only so that they can only update the expiration date.
The Missing Piece
The missing piece of this puzzle is we need to be able to pass in the ID of the item in question to the app so that it knows what item we are editing.
1. Create a blank PowerApp
2. Add a Data Connection to your SharePoint List
3. Add an Edit Form
4. Connect the Edit Form to your Data Source and surface up necessary fields
5. On your Screen with your form, switch to the “OnVisible” property and add the following functions:
The first thing I’m doing is using the ResetForm function to reset the values of our form on load. Lastly, we are using the Set function to create a Global Variable called “varID” and we are going to assign the value of our Parameter to it by using the Param function and passing in the name of our parameter.
|Figure 1 – Set Variable of Parameter|
6. Select your Form and switch to the “Items” property and add the following function:
We are using the First function and then the Filter function and passing in the name of our SharePoint list data source. We are then specifying the filter function of where ID is equal to our Global Variable which was set to the value of the Parameter we are passing in.
|Figure 2 – Set Item Property to Parameter|
7. Save and Publish your PowerApp
8. Go to PowerApps in your O365 and find the PowerApp you want to link to. Click the “…” next to the app and select “Details”
9. Locate the Web Link and copy the URL (this is the link to your App)
10. Now you’ll need to go back to the Flow that we created in Part 1: Using Flow to Send Email Reminder from SharePoint Data so that we can update the e-mail with a hyperlink to our PowerApp.
Go back to the Send Email action in your Flow. In the body of the e-mail we want to put in a hyperlink to the PowerApp. We are going to put in our parameter at the end of this link like below:
The question mark is what is going to tell PowerApps that what follows is a Parameter. Right after the question mark we give the parameter a name, in this case it is ID because it’s the ID of the SharePoint list item. After our parameter name we are using the equal sign to tell it this is the value or our parameter and we are setting that to the ID of our list item using the Dynamic Content.
11. That’s it, all that’s left is to re-publish your Flow and you’ll have a hyperlink in your e-mail that passes a parameter to your PowerApp!