cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JamesM
Level 8

Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

I struggled with this a little bit myself, and I know it's one of those questions that people come up against often. The desire to take Collection data and pass it to Flow as a fully formed JSON array that can be easily worked with in Flow. I came up with the below solution which works really well for me, so I thought I'd provide it in case anyone else needs it Smiley Happy 

 

I have a Gallery collection which has checkboxes. I want to add each checked item to a JSON array prior to passing it to FLOW. Below is my formula for this: 

 

"{" & Mid(Concat(groupStores, ",""" & store_id & """"),2,5000) & "}"

Which produces the following: 

 

{
  "228",
  "721",
  "328",
  "658",
  "655",
  "415",
  "427"
}

Adding or removing from the string correctly re-builds the string with the right quotes and commas etc. Hopefully this helps someone else who needs to do this Smiley Happy 

1 ACCEPTED SOLUTION

Accepted Solutions
Administrator
Administrator

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Thanks for sharing @JamesM! This a great tip that help out future users. Have a great day. 

 

@TopShelf-MSFT

5 REPLIES 5
Super User
Super User

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Thanks for sharing this @JamesM!

Mike8
Level 10

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Hello,

We also use it Smiley Happy
To avoid the mid function you can use the following instead
"{"&Concat(groupStores,""""&store_id&"""",",")&"}"


Also you can set the column names
"{"&Concat(groupStores,"""store_id"":"&""""&store_id&"""",",")&"}"

You can send a table with as many columns as you want from powerapps to flow Smiley Happy
"["&Concat(groupStores,"{""store_id"":"&""""&store_id&"""}",",")&"]"

Administrator
Administrator

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Thanks for sharing @JamesM! This a great tip that help out future users. Have a great day. 

 

@TopShelf-MSFT

Highlighted
johnnyshield
Level: Powered On

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Just in case anyone is searching through this forum, this solution has been superseded by the JSON function

 

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-json

Dawidvh
Level 10

Re: Tip! - Building a valid JSON array from a PowerApps collection (to pass to Flow as an example)

Correct @johnnyshield , the new JSON function works like a charm.

See below video if anyone hasn't used it yet.

https://youtu.be/HLdOO4JPZ2I

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 226 members 4,301 guests
Please welcome our newest community members: