Clear Fix Versions
This workflow removes any values in the Fix versions field when an issue is assigned a state that does not require a fix version. For states like Won't Fix and Obsolete, the Fix version is irrelevant. For Duplicate issues, the Fix versions field should be set when the duplicated issue is resolved.
Name | @jetbrains/youtrack-workflow-clear-fix-versions |
---|---|
Auto-attached | no |
Modules | Clear fix versions when state changes to "Can't reproduce", "Duplicate", "Won't fix", "Incomplete", or "Obsolete" (on-change rule) |
Use Case
This workflow ensures that you don't track issues for product releases if they will not be fixed in any release. It also prevents you from setting a fix version for duplicate issues.
Modules
When an issue is assigned any of the states mentioned in the on-change rule, all values are removed from the Fix versions field.
Clear fix versions when state changes to "Can't reproduce", "Duplicate", "Won't fix", "Incomplete", or "Obsolete"
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: 'Clear fix versions when state changes to "Can\'t reproduce", "Duplicate", "Won\'t fix", "Incomplete", or "Obsolete"',
guard: (ctx) => {
return ctx.issue.fields.isChanged(ctx.State);
},
action: (ctx) => {
const issue = ctx.issue;
const states = [ctx.State.CantReproduce, ctx.State.Duplicate, ctx.State.WontFix, ctx.State.Incomplete, ctx.State.Obsolete];
if (states.filter(function(state) {
return issue.fields.becomes(ctx.State, state);
}).length && issue.fields.FixVersions.isNotEmpty()) {
issue.fields.FixVersions.clear();
workflow.message(workflow.i18n('\'Fix versions\' have been cleared.'));
}
},
requirements: {
FixVersions: {
name: 'Fix versions',
type: entities.ProjectVersion.fieldType,
multi: true
},
State: {
type: entities.State.fieldType,
CantReproduce: {
name: 'Can\'t reproduce'
},
Duplicate: {},
WontFix: {
name: 'Won\'t Fix'
},
Incomplete: {},
Obsolete: {}
}
}
});
Last modified: 08 March 2021