I am returning three sets of comma delimited strings from Microsoft Flow to PowerApps. I can't return an array or complex object because of the nature of the Respond to PowerApps function. Let's say my three strings like like this:
australia, germany, usa, new zealand
440,308,349,299
one,two,three,four
Each set of strings will always have the same amount of values in them, so 4, 4 and 4. Is there any way to somehow combine these together to bind to a Gallery? So I can have.
Gallery Item 1:
- Australia
- 440
- one
Gallery Item 2:
- Germany
- 308
- two
and so on? I'm hoping there is. (This is all from tryng to get nested XML elements back from Flow to PowerApps in order to build a set of on-screen elements based on the info).
Solved! Go to Solution.
O I love problems like this!
Big idea here is that every nth record lines up among the 3 tables--knowing this is going to help us.
There is no way to unite them out of the box. You'll need to bring them together with a repeated action. And when I think of repeated actions, I think of ForAll().
Below is the formula I'm suggesting:
Clear(joint_collection); ForAll(any_table, Collect(joint_collection, { column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result, column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result, column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result... } ) )
Let's take this apart.
Clear(joint_collection); ForAll(any_table, Collect(joint_collection, { column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result, column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result, column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result... } ) )
The closest I've come is splitting each string and using that split as a column in a new collection,
Set(offers,GetMemberSisterClub.Run("2701126726055")); ClearCollect(offerNames,Split(offers.offername,","));ClearCollect(offerExpiries,Split(offers.expiry,",")); Collect( OfferList, { OfferName: Split(offers.offername,","), OfferExpiry: Split(offers.expiry,",") } )
But it produces columns that have a table inside them, instead of columns of individual values for each row.
Hi @JamesM
This might not be the answer you're looking for, but I think it would be easier if you could modify your Flow so that it returns the results in a 'tabular' layout that you can bind to your Gallery.
@Mr-Dang-MSFT wrote a great article on how to output JSON from the 'Respond to PowerApps' function in Flow. I think it's worth trying the same technique.
https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/
Also, @ericonline posted a similar question the other week. Perhaps Eric might be able to share how he worked around this issue.
O I love problems like this!
Big idea here is that every nth record lines up among the 3 tables--knowing this is going to help us.
There is no way to unite them out of the box. You'll need to bring them together with a repeated action. And when I think of repeated actions, I think of ForAll().
Below is the formula I'm suggesting:
Clear(joint_collection); ForAll(any_table, Collect(joint_collection, { column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result, column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result, column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result... } ) )
Let's take this apart.
Clear(joint_collection); ForAll(any_table, Collect(joint_collection, { column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result, column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result, column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result... } ) )
Hi everyone, thank you so much for all the great responses, including @Mr-Dang-MSFT and @timl. Your suggestions combined with a couple of other threads here allowed me to settle on the following which has allowed me to iterate through each collection and combine them into a single collection for use in the gallery! This is part of what I love about PowerApps, you're unlikely to find many communities as eager to share and collaborate to bring about success for everyone as creators! <3!
Set( offers, GetMemberSisterClub.Run("2701126726055") ); ClearCollect( offerNames, Split( offers.offername, "," ) ); ClearCollect( offerExpiries, Split( offers.expiry, "," ) ); ClearCollect( offerAvailBalances, Split( offers.availbalance, "," ) ); ClearCollect( offerOpenBalances, Split( offers.openingbalance, "," ) ); ClearCollect( counter, 0 ); Clear(Combined); ForAll( offerNames, Collect( counter, Last(counter).Value + 1 ); Collect( Combined, { offerAvailBalances: Last( FirstN( offerAvailBalances, Last(counter).Value ) ).Result, offerOpenBalances: Last( FirstN( offerOpenBalances, Last(counter).Value ) ).Result, offerNames: Last( FirstN( offerNames, Last(counter).Value ) ).Result, offerExpiries: Last( FirstN( offerExpiries, Last(counter).Value ) ).Result } ) )
While this is working great, I do look forward to being able to return more complex types from Flow to PowerApps, such as JSON, XML or other easily serializable / de-serializble data formats 🙂 Below is my current UI, the gallery will be the recipient of this data set allowing customers to navigate through their available loyalty offers 🙂 (And yes, the pink is intentional, it's part of the brand 🙂
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
202 | |
69 | |
49 | |
45 | |
20 |
User | Count |
---|---|
258 | |
120 | |
84 | |
77 | |
69 |