YouTrack Standalone 2021.2 Help

One Vote Comment

This workflow adds a vote to an issue if the comment contains "+1".

Name@jetbrains/youtrack-workflow-one-vote-comment
Auto-attachedyes
ModulesAdd 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"

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); const regex = /\s|,|;|\.|\?|!/; exports.rule = entities.Issue.onChange({ title: 'Add vote to issue when comment contains "+1"', guard: (ctx) => { return ctx.issue.comments.added.isNotEmpty(); }, action: (ctx) => { const issue = ctx.issue; let index = -1; issue.comments.added.forEach(function (comment) { if (index < 0 && comment.text) { 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: 08 March 2021