- Variables In MS Flows
- Data Types
- Initialize The Variables
- Increment and Decrement Variables
- Append to String Variable
- Append to Array Variable
Variables :- You can create a variable and declare its data type and initial value all within one action in your flow. You can only declare variables at the global level, not within scopes, conditions, and loops.
The Different Actions we can perform by using variables :-
Initialize variable
set variable
Increment variable
Decrement variable
Append to string variable
Append to array variable
Data Types :-
Boolean :- where the values should be True or False
Integer :- where the values should be numeric only
Float :- It will be used to indicate only fractional values
String :- Alphabetic values
Object :- it can display only objects
Array :- It is nothing but collection of values
We can only initialize variables at the starting of the flow when we initialize them in the middle we will get the error message as shown below where i have initialized variables in apply each action.
Initialize variable :- Create an instant flow and add “initialize variable” action to the flow & Add “Get items” action to the flow to display the SharePoint list items in flow.
Set variable :- Add the “Apply to each” action to the flow to perform the action an every item in the list. Add the “Set variable” action to the flow under apply to each action as shown below
The list which we are going to use in our flow. Here Title column is having the digits in random order so lets reorder the values in increment order by using flow.
Just add the “update item” action to the flow to update the list
Increment variable :- Add “Increment variable” to the action to keep the title column digits in increment order. use the variable which we already initialized in the action and give the value as 1 because we are increasing the value every time with 1.
Save the flow and test it. open the list and refresh it to make the changes which we are doing in the flow.
Now the Title column values are arranged in increasing order.
Decrement variable :- To reorder the Title column values in descending order Initialize 2nd variable and give it a name and select the data type. Give the value as 15 because the total items in the list is 15 .
Remove the “Increment Variable” action and Add the “Decrement Variable” action to the flow
Now add the variable and value to the action.
After that save the flow and Test it.
Now refresh the list we can see the Title column values are arranged in Descending order
Append to String variable :- Append to string variable can be used to append any value to the string.
After initializing a variable by selecting string type , Add “Append to string variable” action to the flow where the value will be appended to the string which is initialized in the variable.
To display the Result Add the compose action to the flow and add the variable to it.
Save the flow and Test it.
After the flow runs the compose action will be displayed like shown below where the string is appended like “Rishan Solutions”
Append to array variable :- Append to array variable will be used to append a value to the array.
Initialize a variable by selecting Data type as Array and add an array as shown below
Add “Append to array variable” action to the flow and add a value which is to be appended to the array
Add “compose” action to the flow and give it a variable.
Save the flow and Test it .
The result will be displayed in the flow where the appended value is “four” to the array