Overview

The Coalesce Block functions similarly to the COALESCE function in SQL, returning the first non-null value from a list of inputs. In Lawme, “null” includes values that appear as “Not Ran” in the UI - blocks that have been excluded from the run due to control flow processing.

This block is particularly useful when working with a set of blocks where only one will run, allowing you to return the output of the first block that actually executes. See the examples section for more information on using this with a Match Block.

Inputs

conditional
boolean

If connected, this can be used to run the coalesce block conditionally. If not connected, it’s treated like any other input. If this input is control-flow-excluded, the entire block will be control-flow-excluded.

input[i]
any

One of the inputs to check for nullness. The first non-null input will be passed to the output port. The number of inputs is dynamic based on how many are connected. Each input is numbered sequentially starting from 1.

Outputs

output
any

The value of the first non-null input. If all inputs are null or control-flow-excluded, the output will be control-flow-excluded.

Editor Settings

This block has no configurable editor settings.

Example: Default Values / Null Checks

You can use a Coalesce Block to perform null checks and set default values for a parameter.

  1. Create an If block but do not connect to its input, so it will not run.
  2. Connect the output of the If block to the Coalesce block.
  3. Connect a Text block with a hardcoded value to the 2nd input of the Coalesce block.
  4. Run the flow. The output of the Coalesce block will be the value of the Text block, since the If block was not run.

Example: Getting a Single Value from a Match Block

  1. Create a Match Block with a few different cases, say 1, 2, and 3.
  2. For each case, use an If Block to transform each case into a unique value, say A, B, and C. Use a Text Block connected to the value port of the If Blocks to set the value passed through for each case.
  3. Connect the outputs of each If block to one of the inputs on a Coalesce block.
  4. Connect an input to the Match block so that only one of the cases will run.
  5. Run the flow. The output of the Coalesce block will be the value of the If block that ran.

This pattern is common when working with a Match block - you can get a unique value for each case using an If block, which is not dependent on the value passed into the Match block itself.

Error Handling

The Coalesce block cannot error in normal operation.

FAQ

See Also