# Vote Blocker

This workflow locks an issue so that users cannot vote for the issue after it is resolved.

| Name | @jetbrains/youtrack-workflow-resolved-votes |
| Previous Title | Do Not Vote for Resolved Issue |
| Auto-attached | no |
| Modules |  [Block votes for resolved issues](#do-not-vote-for-resolved-issue) (on-change rule)  |

## Use Case

This workflow helps you keep users from voting for issues that are already resolved.

## Modules

When a user votes for an issue, the on-change rule in this module verifies that the issue is already in a state that is  Resolved.

* If the issue is not resolved, the vote is added to the issue.

* If the issue is resolved, a warning is displayed. The vote is not added to the issue.

### Block votes for resolved issues

```JAVASCRIPT
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.onChange({
    title: 'Block votes for resolved issues',
    guard: (ctx) => {
        return ctx.issue.isResolved;
    },
    action: (ctx) => {
        workflow.check(!ctx.issue.isChanged('votes'), 'Voting for a resolved issue is not allowed.');
    },
    requirements: {}
});
```

