YouTrack Standalone 2021.2 Help

Assignee Visibility

This workflow generates a warning when an issue is assigned to a user who is not a member of the group for which an issue is visible.

Name@jetbrains/youtrack-workflow-assignee-visibility-group
Previous TitleAssignee Visibility Group
Auto-attachedyes
ModulesWarn when issue is not visible to assignee (on-change rule)

Use Case

This workflow warns users when they assign an issue to an assignee who is not a member of the group for which an issue is visible. A warning is shown if the visibility of an issue is set to a specific group and the assignee is not a member of the visibility group.

The workflow does not block the user from assigning the issue, but can be used to prompt the user to change the visibility setting for the issue.

Modules

When an issue is assigned to a user, this on-change rule verifies that the user is a member of the visibility group. If not, a warning is displayed.

Warn when issue is not visible to assignee

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Warn when issue is not visible to assignee', guard: (ctx) => { return ctx.issue.fields.isChanged(ctx.Assignee) && ctx.issue.fields.Assignee; }, action: (ctx) => { const issue = ctx.issue; const assignee = issue.fields.Assignee; if (issue.permittedGroups.isNotEmpty() || issue.permittedUsers.isNotEmpty()) { if (assignee.login === issue.reporter.login) { return; } if (issue.permittedUsers.find(function (user) { return user.login === assignee.login; })) { return; } if (issue.permittedGroups.find(function (group) { return assignee.isInGroup(group.name); })) { return; } workflow.message(workflow.i18n('Please take into account that new assignee \'{0}\' isn\'t included into the visibility groups and users!', assignee.fullName)); } }, requirements: { Assignee: { type: entities.User.fieldType } } });

Last modified: 08 March 2021