Heads up! ScriptRunner documentation is moving to docs.adaptavist.com. Adaptavist will keep this site up for a bit, but no future updates to documentation will be published here. ScriptRunner 6.20.0 will be the last release to link to scriptrunner.adaptavist.com for in-app help.

Using Behaviours, you can restrict a comment’s visibility by setting the field options for the commentLevel field. This is a particularly useful feature for those who want to ensure that comments added during edit/transition issue can only be seen by certain users.

Restrict by Role and/or Group

Imagine that you have a workflow step where you want to require the user to enter a comment in order to move forward with the transition. In addition to requiring a comment, you only want users in the Administrators role or jira-administrators group to be able to see this comment.

By using setFieldOptions on the commentLevel field, this can be easily accomplished.

Due to the limitations of behaviours, you can only restrict comment visibility on the Update/Edit Issue, Assign Issue, and Workflow Transition screens. You will not be able to restrict comment visibility if a user adds a comment through the view screen.

Note the use of setFieldOptions. It has two forms:


pass a List (or any Iterable) of Role or Group objects

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def groupManager = ComponentAccessor.getGroupManager()

def group = groupManager.getGroup("jira-administrators")
def role = projectRoleManager.getProjectRole("Administrators")

def formField = getFieldById("commentLevel")

formField.setFieldOptions([group, role])

a Map object, where the keys are in the format "group:groupname" or "role:roleID", and the values are the names of the respective Group(s) or Role(s) that will be displayed in the UI

def formField = getFieldById("commentLevel")

formField.setFieldOptions(["group:jira-administrators": "jira-administrators", "role:10002": "Administrators"])

Results in:


Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.