cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jengwt
Regular Visitor

Build Flow to Retrieve SharePoint-List View for Power App

Hello! I'm basically brand new to Power Automate, Flows, and Apps. I need some help getting a Power App to talk to a SharePoint-List View. This will probably be the first of two posts on this subject. If that is the case, I will link the other post.

 

Here's the situation: A team is using a SharePoint List as the master data source for some product information. I need to connect a Power App to this List to get distinct product-information for a submission form. This is also to keep down manual-maintenance requirements for whenever changes are made to the master List.

The List itself has far too many fields to pull into the Power App using the standard SharePoint List connector (we tried that), so instead we would like the team which owns the List to create a List View which will include only the fields which I need for my App. Since Power Apps don't appear to be able to connect to List Views, I apparently need to query this View in a Flow which will then pass the data along to the App.

 

I have built this Instant Cloud Flow triggered by Power Apps, below. The problem that I seem to be having is getting any data from it into the Power App. Is that because I am missing some step?

jengwt_1-1620662525584.png

I have not been able to find any examples online of someone having done this, but I am thinking that maybe I need to add a response step of some sort into the Flow. But the available response step does not offer a List (or perhaps Array?) as an option for returning data to Power Apps. As this Flow will be returning a list of records to the App, I don't think that the available options will work.

What can I do?

jengwt_2-1620663393733.png

Thanks for your help!

 

This data in the View will be used to populate dropdown combo boxes for the selection of the users:

jengwt_0-1621621344104.png

1 ACCEPTED SOLUTION

Accepted Solutions
jengwt
Regular Visitor

Update 1: Ok, so I've started thinking that I would have to build an array of CSV strings which could be parsed out in the Power App. The question is, how to create one?
I did find this article which builds a single CSV string, but it leaves out a bunch of very important steps: "Return data to PowerApps from a flow". Fortunately, I was able to find some help and have constructed the steps required to achieve what this article demonstrates.

 

Having created your Flow and having "gotten the data":

  1. Initialize an array variable which will contain the CSV string.
  2. Add an "Append array to variable" step and select the field you want to concatenate. If you are getting multiple records in your "Get data" step, Flow will automatically enclose this in an "Apply to each" step.
  3. Add a "Join" step, and select your variable and the delimiting character.
  4. Finally, output the variable using a "Respond to a Power App or flow" step.

 

Now, I'm going to test bringing the data into Power Apps and parsing it out. The next big question will be to figure out how to scale this method for two or three fields and maintain the field relationships for given records.

jengwt_0-1620680199331.png

 

You can also distinctify the items in the string by inserting a "Compose" step between the "Apply to each" and "Join" steps. Then write an expression like this:

union(variables('varProductOrSystem'), variables('varProductOrSystem'))
 "Union" in this context takes the distinct items in multiple arrays. This seems like kind of a janky way to do this, but that's how it's done.
Note that you will have to make sure to adjust your "Join" step accordingly to pull the correct "Outputs", now that you have two of them.
jengwt_1-1621621982704.png

View solution in original post

2 REPLIES 2
jengwt
Regular Visitor

Update 1: Ok, so I've started thinking that I would have to build an array of CSV strings which could be parsed out in the Power App. The question is, how to create one?
I did find this article which builds a single CSV string, but it leaves out a bunch of very important steps: "Return data to PowerApps from a flow". Fortunately, I was able to find some help and have constructed the steps required to achieve what this article demonstrates.

 

Having created your Flow and having "gotten the data":

  1. Initialize an array variable which will contain the CSV string.
  2. Add an "Append array to variable" step and select the field you want to concatenate. If you are getting multiple records in your "Get data" step, Flow will automatically enclose this in an "Apply to each" step.
  3. Add a "Join" step, and select your variable and the delimiting character.
  4. Finally, output the variable using a "Respond to a Power App or flow" step.

 

Now, I'm going to test bringing the data into Power Apps and parsing it out. The next big question will be to figure out how to scale this method for two or three fields and maintain the field relationships for given records.

jengwt_0-1620680199331.png

 

You can also distinctify the items in the string by inserting a "Compose" step between the "Apply to each" and "Join" steps. Then write an expression like this:

union(variables('varProductOrSystem'), variables('varProductOrSystem'))
 "Union" in this context takes the distinct items in multiple arrays. This seems like kind of a janky way to do this, but that's how it's done.
Note that you will have to make sure to adjust your "Join" step accordingly to pull the correct "Outputs", now that you have two of them.
jengwt_1-1621621982704.png

View solution in original post

jengwt
Regular Visitor

Update 2: So not long after I set up the Flow, I was able to pull that data into my Power App. This is also per the instructions of the "Return data to PowerApps from a flow" article, but, again, they left out some critical steps, which I would like to detail below.

 

Connect the Flow to the App by first selecting the control which you want to use the Flow, then select "Action", and then "Power Automate" on the top toolbar. Then search for the Flow you created. I don't know why mine appears to have a duplicate of the Flow.

jengwt_7-1621620755193.png

 

This will automatically open a characteristic of that control, because Power Apps wants you to immediately define a variable into which the Flow data will be stored. Beware that this could potentially overwrite existing code within the selected controls, so it's best to save your App or copy important code pertaining to the selected-control characteristics before proceeding.

jengwt_6-1621620545766.png

Also, note that there is nothing stopping you from setting this variable elsewhere. Just be sure to delete the inserted Run command prior to doing so. In my case, I wanted the Flow to run when the app loads, so I deleted the above code and selected the On Start property of the app and added in the appropriate code.

jengwt_5-1621620521113.png

Notice that I also set a second variable which splits the "productorsystem" field retrieved from the Flow into a list using the commas which separate the values.

Now I am ready to use that data from my flow in the selected combo box.

jengwt_8-1621620862881.png

 

The problem that I have now is that the Flow is not respecting the View which it's supposed to be querying; it's returning all of the records. I'm have made a separate post about this, Flow is not respecting selected SharePoint-List View .

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,290)