Logic Composer
Variables
Keep and change values while a flow runs, use the results of earlier steps, and work with lists.
Steps pass values to each other through variables. Some variables you declare yourself with New Variable. Many more appear on their own: almost every step publishes its result under its own name, so a later step can use GetCase.title or DiscountCheck.Output.Discount without any extra work. In expressions, you pick all of them from the expression editor, next to the flow’s inputs and Data items.
Kinds of variables
Section titled “Kinds of variables”| Kind | Where it comes from | Example | Visible to |
|---|---|---|---|
| Declared variable | A New Variable step. Its name is the step name. | Total, FollowUp |
Every step after it |
| Step result | Steps that read or create something publish it under the step name. | GetCase, OpenOpps.Output.value |
Every step after it |
| Loop variable | Loop, Iterator and Try / Catch publish values for the steps inside them. | EachContact.Item, SyncTry.Error |
Only the steps inside that step |
Inputs and Data items are available to every step too. They appear in the expression editor alongside the variables.
Step results
Section titled “Step results”Each step’s variables are named after the step, so give steps short, meaningful names. The list below covers every step that publishes variables.
| Step | Variables | Holds |
|---|---|---|
| Get Entity By Id | <Step> |
One row with the chosen columns; empty when no row has that id |
| Get Entities By Relationship | <Step> Entities |
List of related rows |
| Execute Query | <Step> |
One row (Single), a list of rows (All) or one page of rows (Sliced) |
| Aggregate Query | <Step>.Output.value |
The count, sum, average, minimum or maximum |
| Update / Delete Records from Query | <Step>.Output.recordCount |
Number of rows changed or deleted |
| Clone Record | <Step>.Output.recordId |
Lookup to the copy |
| Queue (Add to queue) | <Step>.Output.queueItemId |
Lookup to the new queue item |
| Create Email | <Step>.Output.emailId |
Lookup to the email |
| Resolve Recipients | <Step>.Output.users |
List of user lookups |
| Run Logic Block, Run Logic Flow, Run Process Action, Execute SDK Message | <Step>.Output.<name> |
One variable per output |
| Loop | <Step>.Counter, <Step>.Start, <Step>.Count |
Current counter value and the bounds |
| Iterator | <Step>.Item, <Step>.Index |
Current item and its position (starting at 1) |
| Try / Catch | <Step>.Error |
The error message (Text), inside Catch only |
| Call Rest Api | [<Step>][Request], [<Step>][Response][<code>], Response Text, [<Step>][error] |
Request body, parsed response per status code, raw response text, call error |
Steps that change data without returning anything new (Save Entity, Assign Record, Set State / Status, Recalculate Rollup and others) publish no variables. Save Entity writes the new id back into the row variable you saved.
Declare a variable
Section titled “Declare a variable”Add a New Variable step. The step name becomes the variable name, and you choose a Type:
| Type (Dataverse) | On-premises label | Holds |
|---|---|---|
| Yes/No | Two Options | Yes or No |
| Date and Time | Date and Time | A date and time, with a behavior: Date Only, Time Zone Independent or User Local |
| Decimal Number | Decimal Number | An exact decimal |
| Floating Point Number | Floating Point Number | An approximate number |
| Currency | Currency | A money amount |
| Whole Number | Whole Number | An integer |
| Text | Text | Text |
| Row | Entity | A row of the table you choose |
| Lookup | Lookup | A reference to a row of the table you choose |
| Choice | Option Set | One option of the choice you choose |
| Template Definition | Template Definition | One row shaped by a template from the Templates tab |
| Object | Object | An object; offered only when objects are defined |
Once the type is complete, choose one value or List of values. A line under the type says what the variable holds, for example “Holds a list of Contact rows.”
Dynamics 365 CE on-premisesType labelsApplies to the other edition
On-premises shows Two Options, Entity and Option Set where Dataverse shows Yes/No, Row and Choice.
Change a variable
Section titled “Change a variable”Use Update Variable. Pick the Variable (fixed once saved), then:
- for a Row or Object variable, add one line per field, each with an operator and a value;
- for any other variable, set its Value: an operator plus an expression.
| Operator | What it does |
|---|---|
| Set | Replaces the value (or the field’s value) with the expression’s result. |
| Set to Nothing | Clears the value. |
| Add Item To Collection | Adds an item to a list variable. |
| Remove Item From Collection | Removes an item from a list variable. |
Step results such as a row read with Get Entity By Id are variables too, so you can change fields of a row you read and save it back with Save Entity.
Update a variable from inside a branch, loop or Try
Section titled “Update a variable from inside a branch, loop or Try”A variable declared earlier in the flow can be updated from anywhere after it: inside a Condition branch, a switch case, a Loop or Iterator, or a Try, Catch or Finally branch. The change is visible after the step that contains it. This is how you keep a running total or collect items across loop iterations.
Work with lists
Section titled “Work with lists”- Collect items: declare a list variable (for example a Lookup to Contact with List of values) and use Add Item To Collection inside an Iterator.
- Use a list: pass it to Iterator’s Collection, to Associate Multiple Relationship’s Entities, to Create Email’s To, or to list functions such as Collection Count, Filter and Projection.
- Build rows in bulk: collect Row variables in a list, then create them all at once with Execute Multiple Request.
Examples
Section titled “Examples”Running total. Add up the value of an account’s open opportunities while you loop through them:
- New Variable
PipelineTotal, type Currency. - Iterator
EachOppoverOpenOpps(an Execute Query with Multiplicity All). - Inside the Iterator, Update Variable
PipelineTotal→ SetPipelineTotal + EachOpp.Item.estimatedvalue.
For a total like this, an Aggregate Query with Sum is faster, because the sum is calculated by the server without reading the rows. Use the loop when you also need to act on each row.
New row. Create a follow-up task:
- New Variable
FollowUp, type Row (Task). - Update Variable
FollowUp: Set Subject toConcatenate("Follow up: ", GetCase.title), Regarding toCaseId, Due Date toAdd Days(Now, 2). - Save Entity with Entity =
FollowUp. After the save,FollowUpholds the id of the new task.