Function Examples
The priority of the task should reflect the highest priority of all subjects:
max(subjects.{subject|subject.priority})
Example: A bug refers to one or more builds, that are affected by this bug (via a custom reference field, for example, choiceList[1]). Each build is a configuration item, that itself refers to a release (via the Versions field). Different builds can belong to the same release. The field Detected in (Release) of the bug should now be automatically computed to reflect the releases of all builds affected by this bug:
distinct(choiceList[1].{build|build.versions.{version|version}})
* 
Nested projections can be used.
Example of a nested projection execution:
List result;
for (Object build in choiceList[1]) {
for (Object version in build.versions) {
result.add(version);
}
}
return distinct(result);
Example: the severity of an item should be the highest severity of all subjects:
List(min(subjects.{subject|subject.severities.{severity|severity}}))
or
first(1, ascending(subjects.{subject|subject.severities.{severity|severity}}))
Note that Severity is a choice list/field, so the field value is a list of choice options. By default, only one list element is allowed. Severity choice options are ordered descending from highest to lowest, so users must use min or first in order to get the highest severity.
Example: Show the last two comments on the tracker item:
join(first(2, reverse(distinct(attachments.{attachment|attachment.description}))).toArray(), "\\\\")
That reads as:
Collect the comments of all attachments:
attachments.{attachment|attachment.description}
Remove all duplicates and empty comments:
distinct(...)
Reverse the order of comments (last comment first):
reverse(...)
Extract the first 2 comments (due to reverse order, these are the last/newest 2 comments in descending order):
first(2, ...)
Concatenate the comments into a single string, separated by a Wiki line break:
join(... .toArray(), "\\\\")
Was this helpful?