...
Code Block |
---|
{% set linkIssues = issue | linkedIssues("Initiative Contains") | field("fields.project.key") %} {% set uniqueProjects = [] %} {% for project in linkIssues %} {% if uniqueProjects.indexOf(project) === -1project not in uniqueProjects %} {% set _ = uniqueProjects.pushappend(project) %} {% endif %} {% endfor %} {{ uniqueProjects }} |
Explanation:
...
linkedIssues
...
Function: Fetches the linked issues based on the specified link type
...
("Initiative Contains").
...
field Function: Extracts the project keys (
fields.project.key
) from the linked issues
...
.
Initialization: An empty list
uniqueProjects
is initialized to store unique project keys.
...
In the loop, each project key is checked against the uniqueProjects
list.
For Loop: Iterates over each
project
inlinkIssues
.Condition Check: Checks if the
project
is not already inuniqueProjects
.Appending Unique Values: If the
project
is not present (not in uniqueProjects
), it is appended to theuniqueProjects
list.Output: Finally, the unique project keys are printed out.
Conclusion: Following the provided approach, you can effectively extract unique values from an array while mitigating duplicate entries. This ensures accurate data representation, particularly in project management contexts where distinct project associations are essential.
...