YouTrack Standalone 2017.1 Help

Referred Issues

This workflow automatically adds a refers to link when another issue is mentioned by its Id in a comment or description.

File Namejetbrains-youtrack-referredIssues
Auto-attachedno
RulesAdd 'refers to' link if issue ids mentioned in comment/description (stateless)

Use Case

This workflow helps you automate the creation of links between related issues.

This workflow references an issue link type with the name refers to. This is a custom issue link type that is not available in YouTrack by default. To use this workflow, you need to add this issue link type to your system. When you create this issue link type, enter the following values:

FieldDescription
NameReference (or any other name, this does not affect the workflow)
Outward Namerefers to
Link DirectionUndirected

For general instructions, see Create an Issue Link Type.

Workflow Rules

This rule checks the description and comment for an issue for references to other issues. When one or more references are found, the issues are added as refers to links.

Add 'refers to' link if issue ids mentioned in comment/description

rule Add 'refers to' link if issue ids mentioned in comment/description when comments.added.isNotEmpty || description.changed { var text = " "; var issueID = " "; var startID = 0; var referringIssue; var messageText = " "; var issueNumber= " "; var curNumber = " "; var cursor = 0; var separators = " ,;.:\"()?!<>#+|/[]\t\n\r"; var symbol = " "; if (description.changed) { text = description.lowerCase; } else if (comments.added.isNotEmpty) { text = comments.added.first.text.lowerCase; } while (startID != -1) { startID = text.indexOf(project.shortName.lowerCase + "-", startID, opts); if (startID == -1) { break; } if (startID > 0 && !separators.contains(text.substring(startID -1, startID), opts)){ text = text.substring(startID + 1); continue; } issueNumber = text.substring(startID + project.shortName.length + "-".length); while (cursor < 10) { symbol = issueNumber.substring(cursor, cursor + 1); if (separators.contains(symbol, opts)) { break; } curNumber = curNumber + symbol; cursor++; } issueID = project.shortName + "-" + curNumber; text = text.substring(startID + issueID.length); if (curNumber.is(numeric)) { referringIssue = loggedInUser.getIssues(project, "#" + issueID); if (referringIssue.isNotEmpty && referringIssue.first == referringIssue.last) { refers to.add(referringIssue.first); if (messageText.isNotEmpty) { messageText = messageText + ","; } messageText = messageText + referringIssue.first.getId(); } } } if (messageText.isNotEmpty) { message(l10n ( Automatically added 'refers to' {messageText} links. )); } }
Last modified: 18 April 2017