Creating a Feedback Form Part 2 – Connecting the Flow
In my last post, I started to create a Feedback form that is using the new possibility to us PowerApps for SharePoint Online list form customization. The first part shows how to create a separated forms for View, Edit, and New action. You should check that out first because we will extend that functionality on this post.
In the old days, you probably have created workflow and send an email when something is added to the list. This type of action is completely valid, and you can still use traditional workflows even in Office 365. But the modern better way to do similar things is to use Flow. For our Feedback form, I wanted to connect the given feedbacks as tasks for our internal team that is building our Intranet.
Let’s add a Flow to our custom form and create a new to do item in Planner that comes as default service for each new Microsoft Group.
From the Feedback list click the PowerApps -> Customize forms from the lists action ribbon.
- This will open the custom app forms application we did in Part 1 of this series.
From the ribbon select Flows.
- This will open the Associated Flows panel.
- Select Create a new Flow.
Flow application will be opened in new tab, and a new flow is created automatically.
- You can see that the flow is associated to PowerApps.
What we wanted to do is to add a new task to Planner so let’s add an action to do that.
- Click New step -> Add an action
- From the opened form search all Planner related action by writing Planner to the search box.
- Select the first action Planner – Create a task
- This will add a new task to your flow. This task is used to create a new task into Planner.
Now you need to connect to correct plan and bucket where you want to add the tasks.
- From Plan Id select the drop-down menu by clicking the down arrow in the field.
- This will open a form showing all available Planner plans.
- Select the one you want to use.
- Do the same thing for Bucket Id. Except, this time you will see all available buckets found from the plan you selected.
For task Title let’s get the value from a user through PowerApps.
- Select Title field and select dynamic content -> Ask in PowerApps.
- This will create a new PowerApps parameter that we need to populate in our custom form. We will come back to this later.
You could give values for other fields also if you want.
- One option is to add current time and date to Start Date-Time field.
- Select the Start Date field and select dynamic content.
- Open the Expression tab and scroll until you see utcNow().
- Click utcNow and click OK.
- Now we have a task that creates a new task to Planner and uses the title detail that the user created as task title.
But we are asking some more information from the user also, so let’s add the value from the Description field also into the task.
- Add a new step after the first task above and add a new action.
- From task selection form again, search planner but this time select Update task details.
To update the new task we just created, select Task Id field and Add dynamic content.
- From the list select Id.
- The created task will send us the details of the created task, and we can now use that info to find it and update the details.
Next, select the Description.
- From dynamic content, menu select Ask in PowerApp to get the value from our custom form.
Finally, click the default name next to Flow name at the beginning of the form.
- Give the flow a name you desire to use.
- Click Create flow.
- Finally, you can click Done, and our flow is completed.
At this point, we have a custom form and a flow that does the task creation. But we still need to combine these two, so that right after a new task is created a new task will be created automatically. Of course, we could attach the flow in New Item Added event on the list, but for this example, we will add the flow straight to our custom form.
- Go back to the list and open the custom form PowerApp.
- Open the NewFormScreen we created in Part 1.
From the screen select CustomNewForm.
- Expand the Title and Description card details. You need the see the name of the fields of the cards later on.
While the form is selected choose OnSuccess event from the attribute drop-down.
- This event is run every time a new item is added successfully to the list.
- By default, it includes two actions. One for clearing the form and another one to close the panel.
- Copy the current OnSuccess value and save them for later use.
From the ribbon select Action -> Flows
- You should see the flow you created earlier.
- Select the flow, and it will be added as a task to the OnSuccess event.
Now we need to give those two parameters, Createatask_Title and Updatetaskdetails_Description, we decided to ask for the app.
- We will connect the form fields to the Flow task call to get the text user has given.
The field value reference can be done based on the field name on the card.
- The name depends on your environment, but on this example, the names are DataCardValue2_1 for Description, and DataCardValue1_1 for Title.
- With the name, you can refer to the Text value and use that on the Flow call.
Finally add the default tasks back to the OnSuccess action so that the form will be reset and closed when everything is done.
- Here’s the whole value used in the example: NewIntranetFeedback.Run(DataCardValue1_1.Text, DataCardValue2_1.Text); ResetForm(CustomNewForm); RequestHide()
- Now save and publish the app to SharePoint.
Navigate back to your list and start to add a new item. After the save check from Planner (https://tasks.office.com/) that a new task is added for future steps.