Define a variable with multiple properties
Power Automate Desktop provides many actions for working with variables.
However, while there are actions for ordinary strings, numbers, dates, lists, and so on, there’s no action for defining an object with multiple properties.
There’s no ready-made action for this, but with a little ingenuity, you can define a variable with multiple properties in a single action.
This article explains the steps.
How to define a variable with multiple properties
Section titled “How to define a variable with multiple properties”This article uses the “Set variable” action.
The action has the following parameters.
| Parameter | Value |
|---|---|
| Variable | The name of the variable to create |
| Value | The value to store in the variable |
In addition to strings and numbers, you can write code directly in this “Value” field.
By taking advantage of this and passing an expression that represents an object directly to “Value”, you can define a variable with multiple properties (a custom object).
Implement by copying and pasting
Section titled “Implement by copying and pasting”As a sample, this article uses a flow that defines a variable whose initial value has properties holding two different data types.
Copy the following code and paste it into the Power Automate Desktop flow designer to add the action.
SET InitializedObject TO { 'prop': 'value', 'array': ['itemA', 'itemB'] }Implement in Power Automate Desktop
Section titled “Implement in Power Automate Desktop”-
In “Search actions”, type “Set variable”.
-
Set the parameters as follows.
Parameter Value Variable %InitializedObject% Value %{ ‘prop’: ‘value’, ‘array’: [‘itemA’, ‘itemB’] }% -
When you run the flow, a variable with multiple properties (a custom object) is defined.