How to Initialize String Variable in Power Automate

In this Power Automate Tutorial, we will discuss How to Initialize String Variable in Power Automate.

Also, we will discuss what is Power Automate Initialize String Variable Array, How to work with Power Automate Initialize String Variable empty, and How to initialize variable date in Power Automate.

Also, Read: How to Initialize Array Variable in Power Automate

Power Automate Initialize String Variable

Let us see how to initialize the String Variable in Power Automate with an example.

I had a requirement where I have to display data from the SharePoint list which is of String data type. So here we will initialize String Variable type and then display the data from the SharePoint list in Power Automate.

So here I have created a SharePoint list called EmployeeList shown below consisting of different columns called,

  • FirstName(text data type)
  • Last Name(Person data type)
  • Employee Code (Integer Data type)
  • Designation (Choice Data type)
Power Automate Initialize Variable String
Power Automate Initialize Variable String

To achieve this follow the below steps:

  • Login into the Power Automate flow and then select the + create flow and click on the Automated cloud flow.
  • Enter the flow name and choose the trigger as When an item is created or modified and click on the create option as highlighted below:
Initialize Variable String in Power Automate
Initialize String Variable in Power Automate
  • Then we will add an action to initialize the variable i.e. initialize the variable.
  • Once initialized, we will enter the variable name, choose the string variable type, and add the dynamic content value in the value section.
  1. Name– Variable Name (VarName)
  2. Type– Variable Data type (String)
  3. Value– Add the dynamic content Variable Value (Title, LastName)

Here Title value contains the FirstName value. Because in SharePoint List we have renamed the Title column name as FirstName. So while passing the dynamic content value we have to add the default Site column name called Title and LastName.

Initialize Variable String in the Power Automate
Initialize String Variable in the Power Automate

We will add a compose action to get the output from the input of the initialized variable which consists of the title value and last name.

Example of Power Automate Initialize Variable String
Example of Power Automate Initialize Variable String
  • Save the flow and select the Test option and choose Manually and click Test.
  • In the SharePoint list, here I have created a new list item as highlighted below so that the Power Automate flow will trigger.
Initialize Variable String in Power Automate example
Initialize Variable String in Power Automate example
  • Once the Power Automate flow has been triggered, we can see the expected output from the SharePoint List as below:
Example of Initialize Variable String in Power Automate
Example of Initialize Variable String in Power Automate

This is how to initialize the String Variable in Power Automate flow with an example.

Check out: How to Initialize Boolean Variable in Power Automate

Power Automate Initialize String Variable Array

Here we will see how to initialize the variable with the string Array type in Power Automate.

In this example, we will initialize the string array to display the first name and last name values in the array format which is of string data type in SharePoint list. For example: If it is of string array then the array looks like [a,b,c..]

Step:1

  • Once the Power Automated flow has been created, select an action to initialize the variable with the string data type in an array format as displayed below:
  • Enter the name and type of the variable as a string and in the values field add the dynamic content values to get values from the SharePoint List.
Initialize variable string array in Power Automate
Initialize variable string array in Power Automate

After initializing the String variable in an array format, add a compose action to retrieve string values in an array data values from the SharePoint list on Power Automate.

Power Automate initializes a variable array example
Power Automate initialize variable array example
  • To run the Power Automate flow, select the Test option and choose Manually and click the Save & Test option.
  • Here I will modify the existing SharePoint list item as shown below so that the Power Automate flow will trigger.
Initialize variable string array in Power Automate example
Initialize variable string array in Power Automate example
  • Once the Power automation flow is triggered and runs, we can see the string values in the array format from the SharePoint list in the compose output section as below:
Example of Initialize variable string array in Power Automate
Example of Initialize String Variable array in Power Automate

This is how to initialize the variable with the string Array type in Power Automate.

Have a look: What is Initialize Variable in Power Automate

Power Automate Initialize String Variable empty

Let us see how we can initialize String Variable empty in Power Automate,

In this example, we will create an instant cloud flow to manually trigger a flow then we will initialize the variable type string empty.

  • Select the + Create flow and click on the Instant cloud flow.
  • Enter the flow name and choose the trigger as Manually trigger a flow and click on the create option as displayed below:
Power Automate Initialize Variable
Power Automate Initialize Variable
  • Once the flow has been created, click the + Add step to add action and initialize the variable in the Power Automate flow.
  • Then enter the variable name, choose the variable type as String, and the variable as null value as displayed below:
Power Automate Initialize variable string empty
Power Automate Initialize variable string empty
  • Now we will add another step to add a compose action to get the output from the initialized input variable value.
Power Automate Initialize variable type string as empty
Power Automate Initialize variable type string as empty
  • In the compose action input value, we cannot change the value assigned to the variable.
  • Save and Test the Power Automate flow and Run flow.

In the below screenshot, we can see that the value is empty and the variable type is a string as expected.

Example of Power Automate Initialize variable string empty
Example of Power Automate Initialize variable string empty

This is how to initialize String Variable empty in Power Automate.

Power Automate initialize variable date

In Power Automate, by default, there is no “date” type to initialize the variable on Power Automate. But we can initialize variables for a date on Power Automate flow.

Here we will initialize a variable and get date values with the string data type and then using compose data operation we will display the date value as output.

To implement this, follow the below steps:

In this example, we will initialize the string data type to display the Start Date, DueDate, and TaskCompletedDate.

  • When the Power Automate flow has been created add a trigger and select the SharePoint site address and list name. Here I have selected the Task list below:
Example of Power Automate initialize variable date
Example of Power Automate initialize variable date
  • select an action to initialize the variable in a String format as displayed below:
  • Enter the name and type of the variable and in the values field add the dynamic content date values.
Power Automate initialize variable date
Power Automate initialize variable date

After initializing the variable, add a compose action to retrieve the date data values from the SharePoint list on Power Automate.

Power Automate initialize variable date
Power Automate initialize variable date
  • To run the Power Automate flow, select the Test option and choose Manually and click the Save & Test option.
  • Once the Power automation flow is triggered and runs, we can see the date data values from the SharePoint list in the compose output section as below:
Example of Power Automate initialize variable date
Example of Power Automate initialize variable date

This is how we can initialize variables for a date on the Power Automate flow.

Additionally, you may like some more Power Automate and SharePoint articles:

In this Power Automate Tutorial, we have learned How to Initialize String Variable in Power Automate. We also covered the below-mentioned topics.

  • Power Automate Initialize String Variable Array
  • Power Automate Initialize String Variable empty
  • Power Automate initialize variable date