YouTrack InCloud 7.0 Help

Duplicates

This workflow provides several options for managing duplicate issues.

File Namejetbrains-youtrack-duplicates
Auto-attachedyes
RulesDon't allow duplicates to form a tree structure with height greater than one (stateless)
When is duplicated link added set try to raise priority (stateless)
Reopen issue if no more 'duplicates' links found (stateless)
When have duplicate link set issue state to Duplicate (stateless)
When issue becomes duplicate it must have duplicate link (stateless)

Use Case

This workflow supports several different use cases that help you automatically process duplicate issues.

  • Prevent users from deleting a duplicates link from an issue in a Duplicate state.
  • Ensure that all issues with a Duplicate state are linked to a duplicated issue.
  • Automatically change the issue state to Duplicate when a duplicates link is added.
  • Raise the priority of an issue when a duplicates link is added.
  • Attach duplicates links to a single issue instead of creating duplicates of duplicate issues.

Rules

This workflow includes several different rules that can be applied to manage duplicate issues.

Don't allow duplicates to form a tree structure with height greater than one

The first rule automatically attaches duplicate issues to a single issue. This prevents users from creating a duplicates 'tree' and consolidates all duplicates links in a single issue.

rule Don't allow duplicates to form a tree structure with height greater than one when issue.duplicateCluster.changed || issue.duplicates.changed || issue.is duplicated by.changed { info("Processing duplicate-cluster issue " + issue.getId()); var duplicateRoot = issue.getDuplicateRoot(); if (duplicateRoot != null) { issue.duplicates.clear; if (issue != duplicateRoot) { issue.duplicates.add(duplicateRoot); duplicateRoot.duplicates.clear; } } }

When is duplicated link added set try to raise priority

The next rule attempts to raise the priority of an issue when it is duplicated by one or more issues. If a duplicate issue has a higher priority than the issue it duplicates, the priority of the original issue is raised.

rule When is duplicated link added set try to raise priority when issue.is duplicated by.added.isNotEmpty { if (Priority != null) { for each source in issue.is duplicated by.added { if (project != source.project && issue.project.valuesFor(Priority).first != source.project.valuesFor(Priority).first) { continue; } var priorityOrdinal = Priority.ordinal; var sourcePriority = source.Priority; if (sourcePriority != null) { var sourcePriorityOrdinal = sourcePriority.ordinal; if (priorityOrdinal > sourcePriorityOrdinal) { priorityOrdinal = sourcePriorityOrdinal; issue.Priority = sourcePriority; } } } } }

Reopen issue if no more 'duplicates' links found

The next rule automatically changes the issue state from Duplicate to Open if there are no duplicates links attached to the issue.

rule Reopen issue if no more 'duplicates' links found when State == {Duplicate} && duplicates.removed.isNotEmpty { if (duplicates.isEmpty) { State = {Open}; } }

When have duplicate link set issue state to Duplicate

The next rule automatically changes the issue state to Duplicate when a user adds a duplicates link.

When an issue is updated, this rule checks that the list duplicates links is not empty and the state of this issue is not Duplicate. If a duplicates link is added and the issue state is not Duplicate, the rule verifies that the user has permission to update the State field. If the user has sufficient permission, the issue state is set to Duplicate.

rule When have duplicate link set issue state to Duplicate when duplicates.added.isNotEmpty && State != {Duplicate} { if (State.canBeUpdatedBy(loggedInUser)) { State = {Duplicate}; } }

When issue becomes duplicate it must have duplicate link

The next rule forces users to add a link to a duplicated issue when they change an issue state to Duplicate.

When issue is updated, this rule verifies that the issue state is changed to Duplicate. If the state is changed to Duplicate and the list of duplicates-type links is empty, the user is notified to add a link to a duplicated issue.

rule When issue becomes duplicate it must have duplicate link when State.becomes({Duplicate}) { duplicates.required(l10n ( Add link to a duplicate issue. )); }
Last modified: 29 September 2016