cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Morke
Helper II
Helper II

Help with arrays, jsons and iterations - Azure ARM Deployments

Hi all,

For context:

I'm trying to build a Flow that, using a Sharepoint List and the data in its columns, populated by a Power App Form, builds an ARM Template and deploys an Azure Virtual Machine.

There's an item in this ARM Template which needs to be dynamic, meaning it uses an array of arrays (nested arrays) variable and iterates through them.

In Powershell, this is how the array would look like:

$array = @(
    @{name = "item1";size = "1";serialnumber = 0}
    @{name = "item2";size = "20";serialnumber = 1}
    @{name = "item3";size = "343";serialnumber = 2}
    @{name = "item4";size = "4343";serialnumber = 3}
)

The ARM Template JSON would iterate through each array inside the main array and go through each property of each array.

To do this, the only thing I need to do in Powershell is input this $array as a parameter, problem solved.

 

However, I'm struggling a lot to transform this logic in Power Apps + Flow.

For starters the input from the user:

Sharepoint Lists don't have arrays, so what I did is to add a Repeating Gallery inside a Datacard in the form, Concatenate all the gallery items in a string variable and save this concatenated string in a single column.

So a resulting string, for example, would be:

item1;1;0 | item2;20;1 | item3;343;2 | item4;4343;3 |

 

Now, how do I transform this single string into an array of arrays in Flow?

and how do I use it afterwards?

I thought about using split, but that would only help me splitting the first "layer" of it. 

Any help is appretiated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @Morke,

 

You could following these steps to process the string, convert it into an array:

1. Initialize an array variable, then put the string need to process into an Compose action;

2. Create second Compose action to remove blank spaces by using replace() function, then use split() function to convert the string into an array by using "|" as the separator;

split(replace(outputs('Compose'),' ',''),'|')

Annotation 2020-05-07 073602.png

3. Then put the output of Compose 2 action into Apply to each action, then use length() function to determine whether the current item has value; 

4. If its length not equals to 0, use the split() function again by using ";" as a separator;

5. Use Append to array variable to structure the array of array:

{
 "Name": "@outputs('Compose_3')[0]",
 "Size": "@outputs('Compose_3')[1]",
 "serialnumber": "@outputs('Compose_3')[2]"
}

Annotation 2020-05-07 073654.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-litu-msft
Community Support
Community Support

Hi @Morke,

 

You could following these steps to process the string, convert it into an array:

1. Initialize an array variable, then put the string need to process into an Compose action;

2. Create second Compose action to remove blank spaces by using replace() function, then use split() function to convert the string into an array by using "|" as the separator;

split(replace(outputs('Compose'),' ',''),'|')

Annotation 2020-05-07 073602.png

3. Then put the output of Compose 2 action into Apply to each action, then use length() function to determine whether the current item has value; 

4. If its length not equals to 0, use the split() function again by using ";" as a separator;

5. Use Append to array variable to structure the array of array:

{
 "Name": "@outputs('Compose_3')[0]",
 "Size": "@outputs('Compose_3')[1]",
 "serialnumber": "@outputs('Compose_3')[2]"
}

Annotation 2020-05-07 073654.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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,351)