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

varentities=require('@jetbrains/youtrack-scripting-api/entities');varworkflow=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){returnctx.issue.fields.isChanged(ctx.Assignee)&&ctx.issue.fields.Assignee;},action:function(ctx){varissue=ctx.issue;varassignee=issue.fields.Assignee;if(issue.permittedGroups.isNotEmpty()||issue.permittedUsers.isNotEmpty()){if(issue.permittedUsers.find(function(user){returnuser.login===assignee.login;})){return;}if(issue.permittedGroups.find(function(group){returnassignee.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}}});