YouTrack Standalone 2021.3 Help

Subsystem Assignee


ModulesSet subsystem owner as assignee for new issues (on-change rule)

Use Case




  • The Assignee field is empty.



Set subsystem owner as assignee for new issues

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Set subsystem owner as assignee for unassigned issues', guard: (ctx) => { return !ctx.issue.fields.Assignee && ctx.issue.fields.Subsystem; }, action: (ctx) => { const issue = ctx.issue; const fs = issue.fields; if ((issue.isReported && (fs.isChanged(ctx.Subsystem) || issue.isChanged('project'))) || issue.becomesReported) { if (fs.Subsystem.owner) { if (ctx.Assignee.values.has(fs.Subsystem.owner)) fs.Assignee = fs.Subsystem.owner; else workflow.message(workflow.i18n( "{0} is set as the owner of the {1} subsystem but isn't included in the list of assignees for issues in this project. " + "The workflow that automatically assigns issues to the subsystem owner cannot apply this change.", fs.Subsystem.owner.fullName,; } } }, requirements: { Assignee: { type: entities.User.fieldType }, Subsystem: { type: entities.OwnedField.fieldType } } });

Last modified: 08 March 2021