One Vote Comment
This workflow adds a vote to an issue if the comment contains "+1".
File Name | jetbrains-youtrack-oneVoteComment |
---|---|
Auto-attached | yes |
Rules | Vote for an issue if added comment contains '+1' (stateless) |
Use Case
This workflow helps you track the popularity of an issue by combining feedback in an issue comment with the actual votes applied to an issue.
Rules
This rule scans the content of a comment that is added to an issue. If the comment contains the text "+1", a vote is added to the issue.
Vote for an issue if added comment contains '+1'
rule Vote for an issue if added comment contains '+1'
when comments.added.isNotEmpty {
var separators = " ~`!@#$%^&*()_=[]{}:;'\"|,<.>/?\n\r\t";
var text = " ";
for each comment in comments.added {
text = text + " " + comment.text;
}
text = " " + text + " ";
var plus1 = "+1";
var index = text.indexOf(plus1, opts);
while (index != -1) {
var sepBefore = separators.contains(text.substring(index -1, index), ignoreCase);
var sepAfter = separators.contains(text.substring(index + plus1.length, index + plus1.length + 1), ignoreCase);
if (sepBefore && sepAfter) {
loggedInUser.voteIssue(issue);
if (votes.changed) {
message(l10n ( The single vote is added. ));
break;
}
}
index = text.indexOf(plus1, index + plus1.length, opts);
}
}
Last modified: 18 April 2017