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.
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"
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Clear fix versions when state changes to "Can\'t reproduce", "Duplicate", "Won\'t fix", "Incomplete", or "Obsolete"'),
guard: function(ctx) {
return ctx.issue.fields.isChanged(ctx.State);
},
action: function(ctx) {
var issue = ctx.issue;
var 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: 16 March 2020