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 | Remove tag when issue changes to an unresolved state (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.
Remove tag when issue changes to an unresolved state
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: 'Remove tag when issue changes to an unresolved state',
guard: (ctx) => {
const issue = ctx.issue;
return issue.fields.isChanged(ctx.State) && issue.fields.State && !issue.fields.State.isResolved;
},
action: (ctx) => {
const TARGET_TAG_NAME = 'confirmed';
const issue = ctx.issue;
const oldValue = issue.fields.oldValue(ctx.State);
if (oldValue && oldValue.isResolved) {
issue.removeTag(TARGET_TAG_NAME);
const wasSuccessfullyRemoved = !!issue.tags.removed.find(function (tag) {
return tag.name === TARGET_TAG_NAME;
});
if (wasSuccessfullyRemoved) {
workflow.message('Tag "{0}" is removed', TARGET_TAG_NAME);
}
}
},
requirements: {
State: {
type: entities.State.fieldType
}
}
});
Last modified: 7 November 2024