Relationship Action Has Loop

The Loop entry is listed in the context menu of an Action Descriptor under New Child > Statement.

The statement/tools contained in a loop statement are repeatedly executed. There are three different loop modes supported.

A loop can be ended if one of the following conditions is met:

Attributes:

Attribute Type Description
Mode Select Value Specifies the type of loop. The supported values are:
Elements
The loop processes all elements of a mass processing context.
Conditional
The loop is iterated as long as the specified condition applies.
Endless
The loop is iterated until it is explicitly ended, for example, due to the use of a Break or Exit statement.
Context Name [O] String Specifies the name of a context created by a tool executed earlier in the statement/tool sequence of the action. All statements/tools under the loop statement are executed with this context.
Enabled Condition [O] Enabled_Condition Relationship to an enabled condition which lets you specify the conditions (simple or complex) which are checked at run time and must be true to execute the statement. See Enabled/Visible Condition for more information on how to specify an enabled condition.

Additional information on the Mode's attribute values:

Elements
The loop processes all elements of a mass processing context. Each iteration will be executed in single processing mode with the corresponding element sub-context. Tools executed within a loop iteration only have access to the single sub-context that is currently being iterated. Tool output parameter values returned by tools executed outside the loop are not directly available within the loop iteration. You can use the tool "Return Property Value" from the AWM function package before the loop is started to add tool output parameters to the mass processing context.
Once the last element has been processed, the loop will end. Attempting to execute an element loop with a single processing context will result in an error message.
Conditional
The loop is iterated as long as the specified condition applies. The condition will be evaluated before each loop iteration. If the condition is evaluated to false, the loop will end.

Examples

The first example loops over a list of selected elements. It moves the elements to a target folder. The first tool prompts for the target folder. Then the elements are processed one by one, in a loop. The first tool in the loop checks if the file already exists in the target folder. If the file exists, another dialog tool is called to ask the user whether to overwrite the file. If the user confirms the overwrite or the target file does not exist the action is continued and the last tool is called to move the file:


Loop Over Elements

The second example loops over a list of elements returned by a previous statement/tool of the action. The action sets the state of a user story and of all its child tasks to the state Finished. The first tool of the action retrieves all child tasks of the story. It creates the mass context "Tasks" containing the retrieved tasks. Then the elements (tasks) of the mass context are processed in a loop. The tool in the loop sets the state of the task to Finish. The last tool of the action is not part of the loop anymore. It sets the state of the user story to Finished:


Loop Over Elements

The third example is loop of type Endless. The action prompts for a password and validates it until the password is accepted. The first tool of the loop is a dialog prompting for the password. The second tool tries to change the password. If the password change was successful the tool sets the property PROP_NewPasswordValid to true. In this case the loop is ended by a Break statement. Another way to end the loop is to click Cancel on the new password prompt dialog. The action is completed by a tool outside the loop with a dialog confirming the password change.


Loop Endless