Skip to main content

Notifications

Power Automate Fundamentals # 22: Usage of Create Array Function in Power Automate

Power Automate Fundamentals # 22: Usage of Create Array Function in Power Automate

 

Introduction:

In Power Automate, at times we need to merge 2 different strings into an Array we can use Create Array Function so that we can get easily desired result. As an example, let us see how to get an array of emails with 2 strings as well as process to merge two different arrays of questions and answers into a single array.

 

Step 1:

Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and click on Flows on the left-hand side as shown in the below figure.

Usage of Create Array in Power Automate Figure 1.jpg

Step 2:

After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.

Usage of Create Array in Power Automate Figure 2.jpg

Step 3:

After Step 2, name flow as Create Array and take initialize variable and name it as Set Email of 1st person with the following fields

Name : Person 1 Email

Type : String

Value : person1@gmail.com

as shown in the below figure.

Usage of Create Array in Power Automate Figure 3.jpg

Step 4:

After Step 3, take another parallel branch with initialize variable and name it as Set Email of 2nd Person with the following fields

Name : Person 2 Email

Type : String

Value : person2@gmail.com

as shown in the below figure.

Usage of Create Array in Power Automate Figure 4.jpg

Step 5:

After Step 4, take compose action and name it as Create an Array of email strings with Create Array Function and provide input as CreateArray with the following syntax

createArray(object_1: any, ...)

and provide the value as

createArray(variables('Person 1 Email'),variables('Person 2 email'))

and click on ok /Update as shown in the below figure.

Usage of Create Array in Power Automate Figure 5.jpg

Step 6:

After Step 5, and take initialize variable and name it as Set Array of Questions with the following fields

Name : 1st Set of Questions

Type : Array

Value : [1,2,3,4,5,6]

as shown in the below figure.

Usage of Create Array in Power Automate Figure 6.jpg

 

Step 7:

After Step 6, and take initialize variable and name it as Set Array of Answers with the following fields

Name : Answers for the 1st Set of Questions

Type : Array

Value : [1,2,3,4,5,2]

as shown in the below figure.

Usage of Create Array in Power Automate Figure 7.jpg

Step 8:

After Step 7, and take compose variable and name it as Create an Array of Arrays of Questions And Answers with Create Array Function and provide input

createArray(variables('1st Set of Questions'),variables('Answers for the 1st Set of Questions'))

 and click on ok / update as shown in the below figure.

Usage of Create Array in Power Automate Figure 8.jpg

Step 9:

After Step 8, click on save and test the flow and observe results as shown in the figure.

Usage of Create Array in Power Automate Figure 9.jpg

Note:

  1. Make sure to save and run the flow whenever you try expressions.
  2. MS documentation is found at here

Conclusion: In this way we can easily create an array with combination of 2 strings and array of integers with Create Array Function to achieve simple requirement in Power Automate flow.

Comments

*This post is locked for comments