Do you need to append text onto an existing text string in your flow?
For example, if you’re working with a list of items that you want to store in a single string variable, appending allows you to do so without having to concatenate each item individually.
This is essential when you need to combine text data in your flows.
This post will guide you through using string variables and appending new text to them.
What Does it Mean to Append to a String?
Appending to a string means adding or joining additional text to an existing string. Essentially, you’re combining two or more pieces of text into one long text. This process is also known as concatenating strings.
In Power Automate, you can achieve this by using the Append to string variable action. First, you need to create a variable using the Initialize variable action and define it as a String data type. This is crucial since the append action will only work on string variables.
Append to String Variables with Append to String Variable Action
In Power Automate, appending a string to a variable is a straightforward process.
First, create an Initialize variable action in your flow. This will contain the original text to append to.
Give your variable a name such as myString in the Name field. Select the String option in the Type dropdown and add the initial text for your variable in the Value field.
Now when you want to append more text to the existing value of your variable, you can use the Append to string variable action.
- Add the Append to string variable action to your flow.
- Select the variable from the Name dropdown to which you want to append text. The variables you previously initialized in your flow will appear here.
- Add the new text to append into the Value field.
📝 Note: Add a space character at the start of the Value field if you want your text to be separated with spaces. You can also use any other characters at the start such as a comma or semicolon to create lists.
Now when you reference the variable in your flow, you will see the output combines the text!
Append to String Variables with Concat Function
Power Automate also has a function for joining text data.
This function allows you to combine two or more strings into a single one, regardless of whether the data is in a variable or not. You can use this anywhere in your flow where you need to combine string data.
concat(<text1>, <text2>)
<text1>
is the first text value you want to join.<text2>
is the second text value you want to join.
For example, concat('Hello '', 'World!')
will result in the text Hello World!
.
concat(variables('myString'),' This is new!')
The above expression will join your variable with the text This is new!
.
Using the concat function in your flow will allow you to join text to your variable while keeping the variable value unchanged.
Append to String Variables with Compose Action
Appending to a string variable can also be done using the Compose action or within any input field of your flow.
This can work the same way as the concat function without the need to create an expression.
Here is how to use the Compose action or any other input field.
- Add the Compose action to your flow.
- Add the variable or other text to which you want to append to the Inputs field.
- Add the text you want to append to the end of the Inputs field.
The output will combine the text from the variable with your new text! It also does not affect the original variable value.
Conclusions
Appending to a string variable is an easy process.
First, you need to initialize a variable and define its type as String. Only string variables can use the Append to string variable action.
Other methods to concatenate with your variable are available too such as the concat function or simply building the required structure using dynamic content in any input field.
How do you append to text variables? Let me know in the comments!
0 Comments