This Power Automate article explains how to append a string to an array in Power Automate with different examples.
Power Automate append string to array
Let us see how to append a string value to an array in Power Automate.
Example-1:
In this example, we will add an input value for Employee ID and Employee Name. Later, we will pass the Employee Designation as a String value and we will append the string value with the array.
Follow the below steps, to achieve this:
Open Power Automate, Create an instant cloud flow, and add an input value for Employee ID and Employee Name like below:
Where,
- Employee ID – Number type
- Employee Name – Text type
- select an initialize variable action to initialize the variable in an array format. Enter the Variable name and choose the Variable type as array.
- To create an array, pass the below function under the Expression tab and click the ok or Update option.
createArray(triggerBody()['number'],triggerBody()['text'])
Where,
- create array = Function Name
- number = Holds the Employee ID
- text = Holds the Employee Name
Add the Compose action and Pass the String Value as an input for the Employee designation as shown below:
- Now add an Append to array variable action. In the Name section, select the existing array variable that we initialized.
- In the Value section pass the output value of the compose action like below:
To see the output, add a compose action and pass the initialized variable. Save the Power Automate flow.
Run the flow manually and pass the values and click on the Run flow option.
Once the flow ran successfully, we can see the mentioned string value has been appended with the initialized array value.
This is how to append String Value to an array in Power Automate.
Example-2:
Here we will see how to append string value to an array dynamically in Power Automate.
In this example, we will use the below Customers SharePoint List consisting of the below-mentioned columns. Initially, We will create an array variable and then we will append the string value to an array.
- Customer Name – Default title column
- Customer Email – Single-line text
- Contact Details – Number
- Address 1 – Multi-Line Text
- Address 2 – Multi-Line Text
To achieve this, Follow the below steps:
- Open Power Automate, and create an Automated cloud flow with the trigger when an item is created.
- Configure the SharePoint site address and the list name.
- select an initialize variable action from action triggers to initialize the variable in an array format. Enter the Variable name and choose the Variable type as array.
- Pass the dynamic content values of Customer Name, Customer Email, and Contact Details from the list in an array format.
- Now add an Append to array variable action. In the Name section, select the existing array variable that we initialized.
- Pass the String values from the dynamic content of Address 1 and Address 2 from a list to append to the existing array variable in the Value section.
To see the output, add a compose action and pass the initialized variable. Save the Power Automate flow.
To test the flow create a new item in a list, so the flow will trigger.
Once the flow ran successfully, we can see the passed string value has been appended with the initialized array value.
This is how to append string value to an array dynamically in Power Automate.
This Power Automate article clearly explained how to append a string to an array in Power Automate with different examples.
You may like the following Power Automate tutorials:
- How to append multiple values to an array in Power Automate?
- Power automate SharePoint multiple choice column to string
- How to split a string into an array in Power Automate?
- How to remove characters from string in Power Automate?
- Power Automate Concatenate String
- Create an HTML Table in Power Automate
- How to replace text in a Word document in Power Automate?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com