One Vote Comment
This workflow adds a vote to an issue if the comment contains "+1".
Name | @jetbrains/youtrack-workflow-one-vote-comment |
---|---|
Auto-attached | yes |
Modules | Add vote to issue when comment contains "+1" (on-change rule) |
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.
Modules
This module contains an on-change rule that 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.
Add vote to issue when comment contains "+1"
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
var regex = /\s|,|;|\.|\?|!/;
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Add vote to issue when comment contains "+1"'),
guard: function(ctx) {
return ctx.issue.comments.added.isNotEmpty();
},
action: function(ctx) {
var issue = ctx.issue;
var index = -1;
issue.comments.added.forEach(function(comment) {
if (index < 0) {
index = comment.text.split(regex).indexOf('+1');
}
});
if (index >= 0) {
ctx.currentUser.voteIssue(issue);
if (issue.isChanged('votes')) {
workflow.message(workflow.i18n('The single vote is added.'));
}
}
},
requirements: {}
});
Last modified: 17 December 2019