Logic Blocks
What is a Logic Block?
A Logic Block is a function that accepts input and produces one or more outputs. Logic Blocks are immutable functions—they do not change the state of the system. The purpose of a Logic Block is to calculate one or more values in the form of output.
Think of a Logic Block like a mathematical function: given the same inputs, it always produces the same outputs. It reads data but never writes data. It calculates but never modifies. This immutability makes Logic Blocks predictable, testable, and safe to use anywhere in your logic.
Anatomy of a Logic Block
Every Logic Block has:
- Name: A unique identifier for the block
- Description: Documentation of what the block does
- Inputs: Zero or more typed parameters the block receives
- Outputs: One or more typed values the block produces
- Logic: The computation that transforms inputs into outputs
Input and Output
Every input and output has a name and a type. The name identifies the parameter, while the type specifies what kind of data it holds.
Inputs can be:
- Required (must be provided when invoking the block)
- Optional (may be omitted, using a default value)
Outputs are always produced when the block executes successfully.
Invoking a Logic Block
Invoking a Logic Block means calling it with the required inputs and receiving its outputs. When you invoke a Logic Block:
- You provide values for the required inputs
- The block performs its computation
- The block returns its outputs
- You use the outputs in subsequent logic
A Logic Block may also retrieve data from Dynamics 365 during computation. For example, a pricing block might look up the customer's discount tier from their Account record. This data retrieval is read-only—the block never modifies the data it reads.
Types of Logic Blocks
FlowOn Logic provides five types of Logic Blocks, each designed for different scenarios:
| Block Type | Outputs | Best For |
|---|---|---|
| Formula | Single output | Calculations, transformations, lookups |
| Decision Table | Multiple outputs | Structured business rules with conditions |
| Decision Tree | Multiple outputs | Flowchart-style decision making |
| Validation | Boolean (true/false) | Single validation rule |
| Validation Set | Boolean (true/false) | Multiple validation rules evaluated together |
Choosing the Right Logic Block
Need to calculate a single value?
└── Use a Formula
Need to evaluate conditions and return multiple outputs?
└── Is the logic tabular (rows of conditions)?
└── Yes: Use a Decision Table
└── No: Is it hierarchical/branching?
└── Yes: Use a Decision Tree
Need to validate data?
└── Single rule?
└── Use a Validation
└── Multiple related rules?
└── Use a Validation Set
Logic Blocks vs Logic Flows
Logic Blocks and Logic Flows serve different purposes:
| Aspect | Logic Block | Logic Flow |
|---|---|---|
| Purpose | Calculate values | Orchestrate processes |
| State | Immutable (read-only) | Can modify data |
| Outputs | Returns calculated values | Performs actions |
| Complexity | Single computation | Multi-step workflow |
| Use Case | "What is the discount?" | "Process the order" |
Logic Blocks are often used within Logic Flows. A flow might use a Formula to calculate a value, then use that value in subsequent steps.