Build the steps of a logic block

An automation rarely does just one thing. It checks a condition, goes through a list, counts something, then updates a field or sends a message. Each of these actions has to be described clearly so that the automation does exactly what you expect.

With this in mind, HEFLO builds every logic block from steps: a decision that follows a business rule, a loop over a list, a variable that counts, a connector that sets values or sends a message. You add them one by one on the canvas and configure each one in a side panel.

HEFLO lets users:

  • Choose a path with business rules, or let the user choose it
  • Repeat steps for each item of a list
  • Keep a value, such as a counter, while the logic block runs
  • Call HEFLO actions and services, such as Set values or Send Mail
  • Read instances, tasks and records
  • Reuse a logic block inside another one

In this article, we explain which steps you can use and how to configure each of them. To create the logic block itself, see “Create and publish a logic block”.

1. Which steps can I use?

The menu of the + lists only the steps the surface of the logic block accepts.

StepWhat it doesSurfaces
Connector callCalls a service: Set values, Send Mail, Call Web Service and others.All
DecisionChooses a path with business rules.All
User choiceAsks the user which path to take.Form event only
For each (loop)Repeats the steps inside it once per item.All
Load instances, Load tasksReads process instances or tasks.All except Form event
Query recordsReads rows from the data export database.All except Form event
Fetch recordsReads records from a registered web service.All except Form event. Needs the Web Service extension
Start an instanceStarts an instance of another process.All except Form event
Set a variableWrites a variable of the logic block.All
Call a scriptRuns a Function logic block and comes back.All
Log lineWrites a line to the execution log.All
Stop with errorEnds the path with an error message.All
NoteAdds a comment on the canvas. It doesn’t run.All

⚠️ Important — A Form event logic block runs in the user’s browser. Load instances, Load tasks, Query records and Fetch records appear in its menu, but they stop the logic block with an error when it runs from a form. On a form, use only the other steps.

2. Make a decision with a business rule

  1. Insert a Decision and give it a Name, for example a question.
  2. Keep Decided by on Business rule.
  3. In Output 1, enter the Label shown on the path.
  4. In Business rule, choose a rule, or click + to create one in Configure Business Rule. The rule can test the fields of the instance and the parameters of the logic block.
  5. Click Add output to create the next path, and give it a label.
  6. Use the arrows of each output to put them in order.

A Decision named Is it urgent? with two outputs: Urgent, using the business rule KB - Deadline missed, and On time, marked default. The canvas shows the two paths labelled Urgent and default.

The canvas shows one labelled path per output. The output marked default doesn’t need a rule.

The outputs are checked from top to bottom, and the first one whose rule is true is taken. When no rule is true, the default output is taken. Click Make default on an output to make it the default one.

⚠️ Important — Removing an output also removes the steps that only that output leads to.

3. Let the user choose the path

You’ll need:

  • A Form event logic block, run from a form button.
  1. Insert a User choice. Its panel is titled Decision, with Decided by set to The user.
  2. Enter the Question the user will read.
  3. For each output, enter the Option and, if you like, an Explanation.
  4. Click Add option to add more options.
  5. Click Pre-select on the option that should already be selected.

A User choice step named How to approve? with the question How do you want to approve this item? and two options: Approve now and Send to review, the second pre-selected.

When the user clicks the form button, a window shows the question and the options, and the logic block follows the path the user picks.

A choice needs at least two options, and every option needs a name. A logic block started by a field change can’t ask the user: the options appear only when it runs from a button.

4. Repeat steps for each item

  1. Insert a For each (loop).
  2. Choose the Collection:
    • Plan tasks: the tasks of the work plan. Only in Work plan event logic blocks, where it is the default choice.
    • Fixed list: values you type in Items (one per line).
    • Rows from “name”: the result of a Load instances, Load tasks, Query records or Fetch records step placed before the loop.
    • Record list “name”: a record list of the record the logic block applies to.
  3. In Item variable, enter the name the steps inside the loop use for the current item. The default name is item.
  4. Click the + inside the loop to add the steps to repeat.

A For each named For each area with Collection Fixed list, the items Finance, Legal and Board on three lines, and Item variable area. Inside the loop, a Log line step.

The steps inside the loop run once per item, in order. The loop header on the canvas shows the collection and the item name, for example Fixed list · area.

In a Fixed list, each line is one item, read as text. Blank lines are ignored, and spaces at the start or end of a line are removed.

Inside the loop, type a colon (:) in a text field to use the current item.

The value list opened by typing a colon in the Text of a Log line: param.reason, total, area and fields of the instance.

The collections offered depend on the surface and on the steps before the loop. For example, in a Work plan event logic block that loops over Plan tasks, each task offers fields such as planTask.description and planTask.status. A Form event logic block can only loop over a Fixed list.

5. Keep a value while the logic block runs

You’ll need:

  • The variable declared in the Script panel, as explained in “Create and publish a logic block”.
  1. Insert a Set a variable. Its panel is titled Set variable.
  2. Choose the Variable.
  3. Choose the Operation. A Text variable accepts Replace with and Append; a Number variable accepts Replace with and Add.
  4. Enter the Value. Type a colon (:) to use another value.

A Set variable step named Count approval that adds 1 to the variable total, placed after a For each loop.

On the canvas, the step shows the variable and the operation, for example total Add.

6. Call a service

  1. Insert a Connector call.
  2. Choose the Service, for example HEFLO Actions — Set values or Send Mail.
  3. Fill in the fields of the service. For HEFLO Actions — Set values, choose the Field to be modified, the Origin of the value (Field, Constant, Variables or Parameters) and the Value.
  4. Click Add parameter to set more fields in the same step.

A Connector call named Mark as approved using HEFLO Actions — Set values: Field to be modified FieldText, Origin Constant, Value Approved.

On the canvas, the step shows the service, for example Set values.

Each surface offers its own list of services. On some surfaces, the fields of Set values appear on a single row.

💡 Good to know — In a Command logic block that loads its own records, a step that acts on an instance must be placed inside a loop over the loaded records.

7. Read records

  1. Insert a Load instances or Load tasks. Its panel is titled Load records.
  2. In Load, choose One row per instance or One row per task.
  3. In Result, choose List of records, First value or Number of records.
  4. In Save result as, keep or change the name of the result. The default name is rows.
  5. If you like, choose the Process. Naming a process lets you read its custom fields in Custom fields to read.
  6. If you like, add Filters. A filter compares a field with a parameter declared in the step’s own Parameters.
  7. After the step, insert a For each (loop) and choose Rows from “rows” as its collection.

A Load records step named Load open instances loading one row per instance of Process 1 into rows, followed by a For each over Rows from rows that calls a function.

The steps inside the loop act on each loaded instance or task.

Query records reads the data export database of the environment: without a data export database, it has no source to choose from. Fetch records reads a web service registered in the environment.

8. Call another logic block

You’ll need:

  • A published logic block with the Function surface.
  1. Insert a Call a script. Its panel is titled Call.
  2. Choose the Function to run.

A Call step named Build the note inside a loop, running the function KB - Build approval note. The panel explains that the function reads this script's parameters and acts on the same subject.

When the step runs, the function runs from its START to its END, then the logic block continues after the step. The list shows only published functions whose Applies to matches the calling logic block.

⚠️ Important — A function doesn’t receive values of its own. It reads the parameters of the logic block that calls it and acts on the same instance. Give the calling logic block the parameters the function reads, with the same names.

9. Start an instance, write a log line or stop with an error

  • Start an instance starts an instance of another process. Choose the process and its start event. The steps below it act on the new instance. A logic block can’t start the process it is acting on.
  • Log line writes a line with a Level (Information, Warning or Error) and a Text. The lines appear in the result of Run now and in the details of each run.
  • Stop with error ends its path with the Error message you write. The run is recorded as Stopped by the script.
  • Note places a free comment on the canvas, for whoever edits the logic block next.

10. Good to know

  • Plan tasks are for work plans. Only a Work plan event logic block can loop over Plan tasks.
  • Only a form can ask the user. User choice works only in a Form event logic block run from a button, not from a field change.
  • A form doesn’t read records. A Form event logic block can’t read records or start an instance.
  • A function takes the caller’s parameters. You can’t pass values directly to a function.
  • Variables are declared first. A logic block can only write a variable it declares.
  • Every output needs a rule, except the default one.

11. Common questions

A path shows the label “no rule”.
That output has no business rule and isn’t the default one. Give it a rule or click Make default.

A path shows the label “No option name”.
An option of a User choice has no name. Fill in its Option.

The labels of two paths overlap on the canvas.
Long labels can cover each other. Select the step to read every output in the panel.

A function writes empty values.
The function reads the parameters of the logic block that calls it. Declare those parameters in the calling logic block.

A service is missing from the Service list.
Each surface offers its own services. The Fetch records step also needs the Web Service extension.

A run ends with “No branch matched”.
No rule was true and the decision has no default output. Mark one output as the default.

Conclusion

Steps turn a logic block into a complete automation:

  • Decisions based on business rules, or on the user’s choice in a form
  • Loops over fixed lists, loaded records or the tasks of a work plan
  • Variables to count or build a text while the logic block runs
  • HEFLO actions and services, and functions you can reuse

The key point: the surface decides which steps you can use. On a form, keep to the steps that don’t read records.

Was this article helpful?

Related Articles