Skip to main content

UAC Utility: For-Each-Input Loop

Disclaimer​

Your use of this download is governed by Stonebranch's Terms of Use.

Version Information​

Template Name

Version

CS For-Each-Input Loop

1.4.0

Refer to Changelog for version history information.

Overview​

This integration is designed to automate the processing of input data by reading it from a flat file in Windows/Linux or a UAC script data repository. The core functionality revolves around a for-each loop, which iterates through the input data, parsing it using a predefined delimiter (such as a comma, pipe, or any one or two characters).

The parsed data segments are extracted and provided further to UAC tasks or workflows during each iteration. This allows for modular processing, where each task can handle a specific aspect of the data, enabling efficient and organized execution of complex workflows.

info

Starting from version 1.0.2, the Universal Template will support a Universal Controller with the Task Field Resolution Required system property enabled. Ensure that the configuration is completed as outlined in the Configure Universal Task section.

Software Requirements​

This integration requires a Universal Agent and a Python runtime to execute the Universal Task.

Software Requirements for Universal Template and Universal Task​

Requires Python 3.11.X or higher. Tested with the Universal Agent bundled Python distribution.

Software Requirements for Universal Agent​

Both Windows and Linux agents are supported.

  • Universal Agent for Windows x64 Version 7.8.0.0 and later with Python options installed.
  • Universal Agent for Linux Version 7.8.0.0 and later with Python options installed.
  • Python modules required:
    • requests

Software Requirements for Universal Controller​

Universal Controller Version 7.8.0.0 and later.

Network and Connectivity Requirements​

Key Features​

This Universal Extension provides the following key features:

  • Actions
    • Read input from a Windows or Linux flat file.
    • Read input from UAC script type data.
    • Parse each line of input via any single or two characters.
    • Launch UAC task or workflow for every line of the parsed input via REST API.
    • Option to wait and launch UAC tasks or workflows based on the previous execution's completion.
    • Capability to launch UAC tasks or workflows sequentially, in parallel, or staggered by a fixed launch delay, and monitor executions of launched task instances.
    • Restart the for-each loop task from the failed line of input or customize the input lines accordingly in the UAC script data.
    • Option to abort for For-Each-Input Loop task execution when one of the launched child tasks or workflows fails, or to continue with the remaining input rows.
  • Authentication
    • Authentication through HTTP(S)
  • Input/Output
    • Capability to read input from a flat file in Windows or Linux Operating system
    • Can Accept from UAC script data
    • It can also accept input from UAC script data that points to a variable potentially the data coming from predecessors Taks
    • Print the summary of Tasks instances launched for the input data and their status
  • Other
    • It's a UAC utility that helps to iterate through the input data and process it by launching a UAC task or workflow via REST-API

Import Universal Template​

To use the Universal Template, you first must perform the following steps.

  1. This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.
  2. To import the Universal Template into your Controller, follow these instructions.
  3. When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

Modifications of this integration, applied by users or customers, before or after import, might affect the supportability of this integration. For more information refer to Integration Modifications.

Configure Universal Task​

Prerequisites for Creating a Task with This Template:

  1. Create a script named DUMMY of type Data. The script's content can remain empty.

These configurations are mandatory starting from version 1.2.0, as the Universal Template has been adapted to support the Universal Controller when the Task Field Resolution Required system property is enabled.

For a new Universal Task, create a new task, and enter the required input fields.

Input Fields​

The For-Each-Input Loop task contains the following Input fields

Field

Input type

Default value

Type

Description

Select a Function

Required

Trigger by Script Input

Choice

The action performed upon the task execution.

Valid values are:

  • Trigger by Script Input
  • Trigger by reading Target File

Script Input Variable

false

Boolean

Check the box if you need to supply the user defined input by variable

Specify the Input File

Text

Specify the Input File (supports .txt, .csv, .xlsx, .xls)

Ignore Empty or Missing File

false

Boolean

Check this box to exit gracefully (exit code 0) if the input file is empty or missing, instead of failing

Script Input

Optional

Script

Specify the User Defined Input (supports .txt, .csv, .xlsx, .xls)

Script Input

Optional

Text

Script name by Variable

Has Header

Boolean

Check this field if the First row in the input file or script needs to be considered as header

Has Delimiter

Boolean

If needed to parse input by delimiter then specify then check this box

Delimiter

Text

Specify the Variable Delimiter, e.g comma or Pipeline

UAC Task to Trigger

Text

UAC Task to trigger

Insert Into Workflow

Boolean

Check this box to insert tasks into a workflow instead of launching them directly

Predecessors

Text

Comma-separated list of predecessor task names (e.g., "Task1,Task2" or "${{var1}}-Task1)"

Successors

Text

Comma-separated list of successor task names (e.g., "Task3,Task4" or "${{var1}}-Task3)"

Parallel Task Launch

Boolean

Specify if you need launch the UAC Task in parallel for every input read

Launch Delay (seconds)

0

Integer

The number of seconds between consecutive task launches. Each task is launched without waiting for earlier tasks to finish; 0 launches all tasks at once. See Launch Methods.

This field is visible when Parallel Task Launch is checked.

Continue When a triggered Task Fails

false

Boolean

Check to keep launching and monitoring the remaining tasks when a launched task fails or a task cannot be launched. Failures are listed in the summary and the For-Each-Input Loop task ends successfully. When unchecked, failures end the For-Each-Input Loop task in failure as described in Launch Methods.

This field is visible when Parallel Task Launch is checked.

Abort Execution When a triggered Task Fails

false

Boolean

Check to end the For-Each-Input Loop task in failure when a launched task fails. When unchecked, the next input row is launched after a failed task. A task that cannot be launched always ends the For-Each-Input Loop task in failure. See Launch Methods.

This field is visible when Parallel Task Launch is unchecked.

Restart from Failure

Boolean

Check this box if the execution needs to be restart from certain line with the input

Restart Execution Input

Script

Specify the input lines where the job needs to resume execution from

Retrieve Output

STDOUT

Choice

Select which output(s) of each triggered task to retrieve and embed once the task reaches a terminal state. Requires automatic output retrieval to be enabled on the triggered task.

Valid values are:

  • STDOUT
  • EXTENSION
  • STDERR

This field is visible when Insert Into Workflow is "false".

Retrieve STDERR only on failure

false

Boolean

If checked, STDERR is retrieved only for tasks that fail, not for successful tasks.

This field is visible when Insert Into Workflow is "false".

Launch Priority

Text

Provide the Launch Priority

UAC Base URL

Required

Text

Provide the universal controller base URL, eg. https://xxxxxxx.stonebranchdev.cloud/

Authentication Type

Choice

Specify which UAC Authentication Method to use:

  • Basic Auth
  • Bearer Token

UAC Credentials

Required

-

Credentials

Credentials for "Basic" and "Token" Authorization Type. The Credentials definition should be as follows.

  • Universal Controller User as "Runtime User".
  • Universal Controller User Password as "Runtime Password".
  • Universal Controller Bearer Token as "Token".

Verify SSL

Boolean

Check this if you need certificate verification

SSL Certificate Path and File Name

Text

Provide the Path of the certificate for SSL Verification

Launch Methods​

When Insert Into Workflow is unchecked, one task is launched for every input row using one of the following launch methods.

Launch Method

Configuration

Behavior

When a Task Fails or Cannot Be Launched

Sequential

Parallel Task Launch unchecked.

Each task is launched after the previous one finishes.

A failed launch ends the For-Each-Input Loop task in failure immediately. With Abort Execution When a triggered Task Fails checked, the first failed task also ends the For-Each-Input Loop task in failure and the remaining input rows are not launched. When unchecked, the next input row is launched after a failed task.

Parallel

Parallel Task Launch checked and Launch Delay (seconds) set to 0.

All tasks are launched at once and monitored until they finish.

Unless Continue When a triggered Task Fails is checked, a failed launch ends the For-Each-Input Loop task in failure immediately, and if any launched task fails, the For-Each-Input Loop task ends in failure after all launched tasks finish.

Staggered

Parallel Task Launch checked and Launch Delay (seconds) greater than 0.

The task for input row N is launched (N - 1) × Launch Delay (seconds) seconds after the first launch, without waiting for earlier tasks to finish. Each task is reported as soon as it finishes.

Unless Continue When a triggered Task Fails is checked, the first failed task or failed launch stops further launches. Tasks already running are monitored and reported until they finish, then the For-Each-Input Loop task ends in failure.

When Continue When a triggered Task Fails is checked (parallel and staggered), every input row is launched regardless of failures, failures are reported, and the For-Each-Input Loop task ends successfully.

Environment Variables​

Environment Variables can be set from the Environment Variables task definition table.

Environment Variable Name

Description

Version Information

UT_FOR_EACH_POLL_INTERVAL_SECS

The interval, in seconds, at which the status of launched tasks is checked, for all launch methods. Must be a positive whole number; any other value falls back to the default. Defaults to 5.

Introduced in 1.4.0

Task Examples​

Example: Staggered launch with a 30 second delay, abort on failure​

Select a Function is "Trigger by reading Target File" and Specify the Input File points to a comma-separated file whose first row holds the variable names (Has Header checked, Has Delimiter checked, Delimiter ,). UAC Task to Trigger names the task launched for each row, Parallel Task Launch is checked, Launch Delay (seconds) is 30, Continue When a triggered Task Fails is unchecked, and Retrieve Output is "STDOUT". The task for the first row is launched immediately, the second after 30 seconds, the third after 60 seconds, and so on, regardless of whether earlier tasks have finished. The STDOUT of each task is printed as soon as it finishes. If a task fails, no further rows are launched, the tasks already running are monitored until they finish, and the For-Each-Input Loop task ends with exit code 100.

Task Output​

  • Trigger For-Each-Input-Loop Task by reading a Flat File

UAC Task launched with Variables :

  • Trigger For-Each-Input-Loop Task by reading the UAC Script of type data

  • Trigger For-Each-Input-Loop Task by reading the UAC script with input variables from the predecessor task

  • Task execution output: For-Each-Input-Loop

  • Example Workflow: Process Files in Loop

  • Example Workflow: Process Servicenow Infra Create RITM request in a loop

  • Example Workflow: Handling SAP Transport request from Azure DevOps in a loop

Exit Codes​

The exit codes for these Universal Templates are described below.

Exit Code

Status Classification Code

Status Classification Description

Status Description

0

SUCCESS

Successful Execution

SUCCESS: Successful Task execution

1

FAILED

Failed Execution

FAILURE: Authentication configuration error - token not found or invalid auth_type value

2

FAILED

Failed Execution

FAILURE: Input list is empty - no data rows to process

3

FAILED

Failed Execution

FAILURE: Input file exists but contains no data rows

4

FAILED

Failed Execution

FAILURE: Input file was parsed but resulted in no usable data (e.g. file contains only a header row)

5

FAILED

Failed Execution

FAILURE: Exception while monitoring the sequentially launched UAC Task

6

FAILED

Failed Execution

FAILURE: Invalid input_function value

7

FAILED

Failed Execution

FAILURE: Input file does not exist

10

FAILED

Failed Execution

FAILURE: Exception or API error while inserting Task into Workflow, exception during parallel job monitoring, or exception or API error while launching UAC Task (sequential or parallel launch, unless Continue When a triggered Task Fails is checked)

20

FAILED

Failed Execution

FAILURE: Required Python library not installed - openpyxl (for .xlsx) or xlrd (for .xls)

21

FAILED

Failed Execution

FAILURE: Error reading Excel (.xlsx / .xls) or CSV file

99

FAILED

Failed Execution

FAILURE: UAC API response code is not 200 when inserting Task into Workflow, or when launching Job (sequential or parallel launch, unless Continue When a triggered Task Fails is checked)

100

FAILED

Failed Execution

FAILURE: One or more launched Tasks or Workflows ended in a failed status (or, with staggered launch, could not be launched) while Abort Execution When a triggered Task Fails is checked (sequential) or Continue When a triggered Task Fails is unchecked (parallel and staggered)

STDOUT and STDERR​

STDOUT and STDERR provide additional information to the User. The populated content can be changed in future versions of this extension without notice. Backward compatibility is not guaranteed.

Document References​

This document references the following documents.

Document Link

Description

Universal Templates

User documentation for creating, working with and understanding Universal Templates and Integrations.

Universal Tasks

User documentation for creating Universal Tasks in the Universal Controller user interface.

Credentials

User documentation for creating and working with credentials.

Resolvable Credentials Permitted Property

User documentation for Resolvable Credentials Permitted Property.

Integration Modifications​

Modifications applied by users or customers, before or after import, might affect the supportability of this integration. The following modifications are discouraged to retain the support level as applied for this integration.

  • Python code modifications should not be done.
  • Template Modifications
    • General Section
      • "Name", "Extension", "Variable Prefix", "Icon" should not be changed.
    • Universal Template Details Section
      • "Template Type", "Agent Type", "Send Extension Variables", "Always Cancel on Force Finish" should not be changed.
    • Result Processing Defaults Section
      • Success and Failure Exit codes should not be changed.
      • Success and Failure Output processing should not be changed.
    • Fields Restriction Section
      The setup of the template does not impose any restrictions, However with respect to "Exit Code Processing Fields" section.
      1. Success/Failure exit codes need to be respected.
      2. In principle, as STDERR and STDOUT outputs can change in follow-up releases of this integration, they should not be considered as a reliable source for determining success or failure of a task.

Users and customers are encouraged to report defects, or feature requests at Stonebranch Support Desk.

Changelog​

ut-cs-for-each-input-loop-1.4.0 (2026-11-10)​

Enhancements​

  • Added: Staggered launch method. With Parallel Task Launch checked and the new Launch Delay (seconds) field greater than 0, one task is launched every Launch Delay (seconds) seconds without waiting for earlier tasks to finish, and each task is reported as soon as it finishes.
  • Added: UT_FOR_EACH_POLL_INTERVAL_SECS environment variable to set the interval at which the status of launched tasks is checked.
  • Added: Continue When a triggered Task Fails field for parallel and staggered launches. When checked, failed tasks and failed launches are listed, the remaining tasks are still launched and monitored, and the For-Each-Input Loop task ends successfully. It is unchecked by default, which keeps the previous behavior.
  • Changed: Minimum supported Universal Controller and Universal Agent version is 7.8.0.0.

Fixes​

  • Fixed: With Parallel Task Launch checked and Launch Delay (seconds) set to 0, a launched task that ended in Skipped or Running/Problems status is now reported as failed. Previously the For-Each-Input Loop task kept monitoring it indefinitely.

ut-cs-for-each-input-loop-1.3.0 (2026-07-21)​

Enhancements​

  • Added: Surface the output of each launched child task or workflow during execution. By default, the child task's STDOUT is displayed; you can now also choose to retrieve all outputs (STDOUT, STDERR, and Extension Output).
  • Added: New "Retrieve STDERR only on failure" option, which includes STDERR only for child tasks that finish in a failed state.
  • Added: Child task output is retrieved on demand from the agent, so it is displayed even when the referenced task does not have automatic output retrieval enabled.

ut-cs-for-each-input-loop-1.2.0 (2026-05-14)​

Enhancements​

  • Added: Support for predecessors and successors, enabling clearer and more flexible workflow dependencies
  • Added: Proper handling of multiple instances of the same task, avoiding conflicts by using unique identifiers
  • Added: Bearer Token Authentication, simplifying and securing authentication for users

Fixes​

  • Improved task layout by positioning inserted tasks horizontally with consistent 150px spacing
  • Corrected variable substitution so ${{var}} is properly rendered as ${var} in task names and dependencies

ut-cs-for-each-input-loop-1.1.0 (2025-01-16)​

Enhancements​

  • Supports a Controller with the "Task Field Resolution Required" system property enabled
  • Virtual Resource priority can be specified for the launched Task

ut-cs-for-each-input-loop-1.0.1 (2024-08-01)​

Fixes​

  • Exits with RC 2 when the input list is empty

ut-cs-for-each-input-loop-1.0.0 (2024-05-29)​

Initial Version