This template collects the values from a selected field across from all child work items and generates a list, automatically removing duplicate entries.
Configuration
To use the Collect field values in sub-tasks template, simply select it from the template grid. Filter by Portfolio roll-ups & delivery KPIs to find it faster.
Parameters
To complete the configuration, select a field for the required parameter.
Edit formula mode
If you click on Edit formula you can see the Smart field in the Expression Parser. You can now tweak the expression to create a custom smart field based on this template.
Expression
General expression:
%{distinct(fieldValue(%{issue?.customfield_NNNNN}, (%{issue.issueType} = "Epic" ? issuesUnderEpic() : subtasks())))}
NNNNN is the ID of the custom field you chose for the “Field” parameter.
Used parser functions
The links lead to the JWTC documentation because the parser functions are shared functionalities.
Details
1. What does the expression do?
This expression collects all the values from a specific field across all child work items (either sub-tasks or issues under an Epic) and generates a list of unique values, automatically removing duplicates.
2. Step-by-step breakdown
The general expression is:
%{distinct(fieldValue(%{issue?.customfield_NNNNN}, (%{issue.issueType} = "Epic" ? issuesUnderEpic() : subtasks())))}
Let’s break down each part:
-
%{...}: This syntax indicates a parser expression, which is evaluated dynamically. -
customfield_NNNNN: ReplaceNNNNNwith the actual ID of the custom field you want to collect values from. -
%{issue?.customfield_NNNNN}: This retrieves the value of the chosen custom field from the current work item, if it exists. -
%{issue.issueType} = "Epic": Checks if the current work item is of type "Epic". -
issuesUnderEpic(): If the work item is an Epic, this function returns all work items that are under this Epic. -
subtasks(): If the work item is not an Epic, this function returns all sub-tasks of the current work item. -
fieldValue(field, issues): This function collects the values of the specified field from the provided list of work items. -
distinct(...): This function removes duplicate values from the resulting list, ensuring each value appears only once.
The expression uses a conditional (ternary) operator:
-
If the work item is an Epic, it collects field values from all issues under the Epic.
-
Otherwise, it collects field values from all sub-tasks.
3. Examples
-
If you select the field "Component" and use this expression on an Epic, it will list all unique Components used in the issues under that Epic.
-
If you use it on a standard work item (not an Epic), it will list all unique values of the selected field from its sub-tasks.
4. Real-life use cases
-
Roll-up reporting: You want to see all unique labels, components, or custom field values used by the sub-tasks of a work item or by all issues under an Epic.
-
Quality checks: Quickly identify if any child work items are missing a required field value or if there are inconsistencies.
-
Portfolio management: Summarize key field values (like "Release Version" or "Team") across all child work items for higher-level tracking.