How to create an array from a string using Power Automate?

In this Power Automate tutorial, we will see how to create an array from a string using Power Automate.

In Power Automate, we can create an array from String Values in three different ways:

  • array() function
  • createArray() function
  • split() function

Here, I will show you all three ways with examples; in the first example, we will use the array()function; in the second example, we will use the createArray() function; and in another example, we will use the split() function to create an array from string values.

How to create an array from a string using Power Automate

Let us see how to create an array from a string using Power Automate flow,

In all these examples, we will add three input fields called User ID, UserName, and UserRole, which are Text data types in the trigger action in instant cloud flow.

Example-1: (using array() Function)

Step :1

  • Login to Power Automate, and create an instant cloud flow. Expand the trigger and pass the input values of User ID, UserName, and UserRole.
power automate create array from string

Step:2

Add an initialize variable action, choose the Variable type as String, and pass the dynamic content values of User ID, UserName, and UserRole.

power automate build array from string

Step:3

Add a compose action, and pass the below expression to create an array for the string values by using array function.

array(variables('StringValues'))

Where,

  • array – Function Name
  • StringValues – Dynamic content value
power automate get array from string

Step:4

Save and Test the flow. Enter the User ID, UserName, and UserRole details and click on the Run flow:

create array from string using power automate

Our flow ran successfully; we see an array created from string values using Power Automate.

power automate build array from string example

This is one way that we can create an array from string values using Microsoft Flow.

Example-2: (Using createArray() function)

In the same way, Follow the (Step 1 and Step 2) that we discussed in Example:1

Then, Add a compose action, and pass the below expression to create an array for the string values by using the createArray() function.

createArray(variables('StringValues'))

Where,

  • createArray – Function Name
  • StringValues – Dynamic content value
power automate get array from string values

Save and Test the flow. Enter the User ID, UserName, and UserRole details and click on the Run flow:

create array from string using power automate flow

Our flow ran successfully; we can see an array has been created from string values using Power Automate flow.

power automate create array from comma separated string example

This is another way that we can create an array from string values using Microsoft Flow

Example-3: (Using split() function)

Similarly, Follow the (Step 1 and Step 2) that we discussed in Example :1

Later, Add a compose action, and pass the below expression to create an array for the string values by using split function.

split(variables('StringValues'),',')

Where,

  • split – Function Name
  • StringValues – Dynamic content value
power automate create array from string split

Save and Test the flow. Enter the user ID, UserName, and UserRole details and click on the Run flow:

get array from string using the power automate flow

Our flow ran successfully; we see an array created from string values using Power Automate flow.

power automate create array from comma separated string

This is another example of creating an array from string values using Microsoft Flow.

Conclusion

In this tutorial, I have explained 3 different ways to create an array from a string using Power Automate.

You may also like:

>