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 Title | Assignee Visibility Group |
Auto-attached | yes |
Modules | Warn 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
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Warn when issue is not visible to assignee'),
guard: function(ctx) {
return ctx.issue.fields.isChanged(ctx.Assignee) && ctx.issue.fields.Assignee;
},
action: function(ctx) {
var issue = ctx.issue;
var assignee = issue.fields.Assignee;
if (issue.permittedGroups.isNotEmpty() || issue.permittedUsers.isNotEmpty()) {
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
}
}
});