In this example, the if statement assigns an issue and sets the value of the user variable to the project leader when the value for the Assignee field is not set.
If the issue has already been assigned to another user, the else statement sets the value of the user variable to the current assignee.
The following statements can be used to iterate over a sequence of elements.
Creates a loop that executes a specified statement as long as the test condition evaluates to true.
The condition is evaluated before executing the statement.
Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.
When you iterate over a collection with a for each statement, you define an arbitrary variable that references the elements in the sequence in the statement itself.
The following examples from the default workflows illustrate how to use iterations in workflows.
In this example, the for each statement checks the sequence of issues with the duplicatedBy link type.
If the project property of any issue in the sequence matches the current project, the value of the Fixed in build is set.
The variable duplicatedBy represents the sequence of issues that are linked to the current issue with the link name is duplicated by.
Each issue in the sequence is assigned the variable name duplicate.
In this example, the for each statement checks the sequence of issues with the duplicates link type.
If the project property of any issue in the sequence matches the current project and the current value of the Fixed in build is not null,
the value of the Fixed in build is set.
In this example, the sequence of issues that are linked to the current issue have the link name duplicates.
Each issue ini the sequence is assigned the variable name duplicatedIssue.
Warnings and Errors
The following statements display errors or warnings to the user and write messages to the log files in YouTrack.
assert [condition: Boolean]: (string)
A Boolean expression.
The warning text to display on the user interface.
Verifies that a Boolean expression is true. If it is not true, the system throws an error.
All changes are rolled back to the initial state.
If a workflow rule changes the properties of an issue to match the condition for executing a second workflow rule, changes are applied by the second workflow.
This chain of events continues until all of the relevant statements have been executed.
All of the changes are applied in a single transaction.
When an assert statement returns a false value, all of the changes are rolled back.