How to append a string to an array in Power Automate?

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
C:\Users\TSinfo\Desktop\Power Automate append string to array.jpg
  • 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
Power Automate append string to array example

Add the Compose action and Pass the String Value as an input for the Employee designation as shown below:

append string to array in Power Automate
  • 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:
append string to array in Power Automate flow

To see the output, add a compose action and pass the initialized variable. Save the Power Automate flow.

Example to append string to array in Power Automate

Run the flow manually and pass the values and click on the Run flow option.

append string value to array in Power Automate

Once the flow ran successfully, we can see the mentioned string value has been appended with the initialized array value.

Example to append string value to array in Power Automate

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
append string value to an array dynamically in Power Automate

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.
append string value to an array dynamically using Power Automate
  • 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.
append string value to an array dynamically using flow
  • 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.
append string value to an array dynamically using the Power Automate flow

To see the output, add a compose action and pass the initialized variable. Save the Power Automate flow.

append string value to an array dynamically using the Power Automate

To test the flow create a new item in a list, so the flow will trigger.

append string value to an array variable using Power Automate flow

Once the flow ran successfully, we can see the passed string value has been appended with the initialized array value.

Example to Append string value dynamically to an array using Power Automate flow

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:

>