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.
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.
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
Step:4
Save and Test the flow. Enter the User ID, UserName, and UserRole details and click on the Run flow:
Our flow ran successfully; we see an array created from string values using Power Automate.
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
Save and Test the flow. Enter the User ID, UserName, and UserRole details and click on the Run flow:
Our flow ran successfully; we can see an array has been created from string values using Power Automate flow.
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
Save and Test the flow. Enter the user ID, UserName, and UserRole details and click on the Run flow:
Our flow ran successfully; we see an array created from string values using Power Automate flow.
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:
- Convert base64 to an image file in Power Automate
- Create an Array from SharePoint list Items using Power Automate
- Remove an item from an array in Power Automate
- Parse JSON Object to Array in Power Automate
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.