Untag on Reopen
This workflow automatically removes a specific tag from an issue when the state is set from a resolved state to an unresolved state.
Name | @jetbrains/youtrack-workflow-untag-on-reopen |
---|---|
Auto-attached | no |
Modules | Define transitions for "State" field with predefined time constraints (on-change rule) |
Use Case
This workflow helps you manage tags that indicate an issue has been fixed. You can customise this workflow to automatically remove or update inappropriate tags based on a change in the issue state.
Modules
When the state of an issue is set to an unresolved state, this rule removes the confirmed tag from the issue.
Define transitions for "State" field with predefined time constraints
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Remove tag when issue changes to an unresolved state'),
guard: function(ctx) {
var issue = ctx.issue;
return issue.fields.isChanged(ctx.State) && issue.fields.State && !issue.fields.State.isResolved;
},
action: function(ctx) {
var TARGET_TAG_NAME = 'confirmed';
var issue = ctx.issue;
var oldValue = issue.fields.oldValue(ctx.State);
if (oldValue && oldValue.isResolved) {
issue.removeTag(TARGET_TAG_NAME);
var wasSuccessfullyRemoved = !!issue.tags.removed.find(function(tag) {
return tag.name === TARGET_TAG_NAME;
});
if (wasSuccessfullyRemoved) {
workflow.message(workflow.i18n('Tag "{0}" is removed', TARGET_TAG_NAME));
}
}
},
requirements: {
State: {
type: entities.State.fieldType
}
}
});
Last modified: 17 December 2019