Looper Unit Test

Prev Next

Looper Custom Widget v3 – Quick Start and Best Practices

Download the latest version of the Looper widget (v3) with the Looper Unit Test or replace your current one, to experience improvements and bug fixes.

Purpose

The Looper Custom Widget simplifies batch operations on record lists (such as Tulip Table entries) using triggers, removing the need for custom JavaScript. With Tulip's low-code environment, Looper enables you to automate updates, calculations, and other workflows for processing multiple items at once.

Custom widgets like Looper enhance Tulip with capabilities beyond the core platform, making it easy to perform robust, adaptable actions on many records.

How It Works

Looper uses Tulip Custom Widget properties (for input) and events (for output):

  • Loop List (property): The array of items to process (type: text list, read-only).
  • Begin (property): Starts the loop when set to True.
  • Iteration (property): Tracks the current loop index (typically set to 0 to start).

Workflow:

  • You provide a Loop List.

  • Set Iteration to 0.

  • Set Begin to True. The widget fires a Loop Action event for each item in the list, outputting the item.

  • When all items are processed, an End Action event fires.

  • If you try to loop more than 250 items, an Error event fires.

Setup

✅ Recommended Setup

Starting via Button-Click

  • Add a “Start Loop” button to your app interface.

  • When the button is clicked, use a trigger to:

    • Set the Loop List (the list of items you want to process)
    • Set Iteration to 0
    • Set Begin to True
  • Wait for the Looper widget’s visual progress bar to appear before taking further actions. This method is reliable and easy for operators to understand.

Starting on Step Enter with Intermediary Setup Step

  • Insert a new step in your process, e.g., “Setup Looper.”

  • On the setup step (e.g., “Setup Looper.”), in the Step Enter trigger:

    • Set the Loop List
    • Set Iteration to 0
    • Set Begin to True
    • Transition immediately to your primary step (e.g., “Run Looper”).
  • On your “Run Looper” step, DO NOT put any other Step Enter logic. If you need further actions after the loop completes, use the Looper’s End Action event to trigger them.

Important

Always set Loop List, then Iteration = 0, then Begin = True, in this order.
This ensures the widget receives all required data before starting.

Note

On every path in your Loop Action trigger, be sure to increment the Iteration property at the end.

⚠️ Pitfalls to Avoid

Avoid these common mistakes that can cause race conditions, lost data, or unpredictable behavior:

Starting Looper and setting properties directly on the Step Enter trigger of the Looper’s step:

  • The widget may not be fully loaded before triggers run, leading to skipped items or no action.

Using the widget in very loaded or complex apps with fast triggers:

  • Triggers such as timers, machine/device events, or multiple process actions in rapid succession can outpace the widget’s loading sequence.

Using Device triggers, Machine triggers, or fast Timer triggers to start the loop:

  • These may execute just as the step loads, before the widget is ready.

Initializing Looper directly “On Step Enter” without a setup step:

  • There is no guarantee the Looper widget is loaded when Step-Enter fires.

Ultra-fast button clicking immediately after loading a step:

  • User clicks can sometimes come before the widget appears on-screen, causing unreliable behavior.
Important

For smooth automation, always insert a “Setup Looper” intermediary step if you need to start the Looper automatically.

Never combine Looper initialization with other Step Enter logic on the “Run Looper” step.

Example

To see the recommended setup in action, explore the Looper Unit Test app:

What’s in the Unit Test app?

  • Side-by-side demonstrations of both the Button-Click and Setup Step initialization methods

  • Easy-to-follow triggers showing how to:

    • Set the Loop List, Iteration, and Begin properties in order
    • Use the Loop Action event to process items and increment Iteration
    • Run post-loop logic using the End Action event
  • Labeled steps and clear comments for each part of the process

  • Visual confirmations, such as the progress bar and event completions

How to use this example app:

  • Follow the step navigation to see both recommended workflows implemented
  • Use the trigger logic as a template for your own applications
  • Test changes in the safe environment of the Unit Test app before rolling out to production

Tip:

Copy and adapt the illustrated trigger setup from the Unit Test app to ensure robust and reliable looping logic in your own Tulip workflows!