Variables in Power Automate Desktop
Power Automate Desktop Variables: Types and Usage
In Power Automate Desktop (PAD), variables store data that flows through your automation. They can be referenced in actions using %VariableName% format.
1. Text
Stores string values like names, messages, or file paths.
Example:
Set Variable: UserName = John Doe
Display Message: Hello, %UserName%
Set Variable: UserName = John Doe
Display Message: Hello, %UserName%
2. Number
Stores numeric values for calculations.
Example:
Set Variable: Age = 30
Display Message: You are %Age% years old
Set Variable: Age = 30
Display Message: You are %Age% years old
3. Boolean
Stores True or False flags.
Example:
Set Variable: IsApproved = %true%
Display Message: Approval status: %IsApproved%
Set Variable: IsApproved = %true%
Display Message: Approval status: %IsApproved%
4. List
Stores multiple values in a collection. Access items by index.
Example:
Set Variable: EmployeeNames = [John, Mary, Steve]
Display Message: First Employee: %EmployeeNames[0]%
Set Variable: EmployeeNames = [John, Mary, Steve]
Display Message: First Employee: %EmployeeNames[0]%
5. Custom Object
Stores key-value pairs. Access properties using dot notation.
Example:
Set Variable: Employee = {Name: John, Age: 30}
Display Message: Name: %Employee.Name%, Age: %Employee.Age%
Set Variable: Employee = {Name: John, Age: 30}
Display Message: Name: %Employee.Name%, Age: %Employee.Age%
6. Data Table
Represents structured table data, like Excel or SQL query results.
Example:
Read from Excel: Store in %CustomerTable%
Access Row Count: %CustomerTable.Rows.Count%
Read from Excel: Store in %CustomerTable%
Access Row Count: %CustomerTable.Rows.Count%
7. Data Row
Represents a single row from a data table. Access columns by name.
Example:
Set Variable: Row = %CustomerTable.Rows[0]%
Access Column: %Row["CustomerName"]%
Set Variable: Row = %CustomerTable.Rows[0]%
Access Column: %Row["CustomerName"]%
8. Connector Object
Used to store data retrieved from connectors like SQL, SharePoint, or web services.
Example:
Set Variable: SharePointData = Get List Items
Access Property: %SharePointData.Title%
Set Variable: SharePointData = Get List Items
Access Property: %SharePointData.Title%
9. List of PDF Table Info
Used when extracting tables from PDF files. Stores table structures and values.
Example:
Set Variable: PDFTables = Extract Tables from PDF
Access First Table: %PDFTables[0].Rows[0]["ColumnName"]%
Set Variable: PDFTables = Extract Tables from PDF
Access First Table: %PDFTables[0].Rows[0]["ColumnName"]%
10. Best Practices
- Use descriptive variable names for clarity.
- Initialize variables before use.
- Be mindful of variable type to avoid runtime errors.
- Validate data when working with lists, tables, or objects.
Comments
Post a Comment