Groovy: Field Level Permission - Field only unlocked when open Edited

Using Groovy Scriptrunner, is it possible to make the following happen:

The DESCRIPTION field is locked when:
1. User is in PROJECT ROLE ABC
2. Issue status is NOT Open

In other words, users in the project role should only be able to edit the Description field when the status is Open. Once it moves past open, the user can no longer edit the field.

Below are settings that I have tried but the DESCRIPTION field is not locking, regardless of the status. The behavior is mapped to all projects & issue types.


I also attempted to lock the DESCRIPTION field when the status is OPEN (regardless of the project role). This did not work - the add-on did not lock the field.

1 answer

Hi Karrie, 

The except condition is when you are in a transition screen, but I understand you care about the status of the issue. Therefore in your case your will need to add a servier side script that will look like

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

import static com.atlassian.jira.issue.IssueFieldConstants.*

@BaseScript FieldBehaviours fieldBehaviours

def description = getFieldById(DESCRIPTION)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def devProjectRole = projectRoleManager.getProjectRole("Developers")

if (projectRoleManager.isUserInProjectRole(currentUser, devProjectRole, issueContext.getProjectObject()) && underlyingIssue?.status?.name != "Open") {
} else {

PS. That script checks tha name of the status and not the name of the status category, if the later is your case then use 

underlyingIssue?.status?.statusCategory?.name != "Open"

Hope that does the trick.

Regards, Thanos

Thanks! I will give that a try today.

You mentioned that this is a server script, but I am not entirely sure where to save the code.


Under SCRIPT CONSOLE, I changed the project role from "Developer" to "Test" (it is a valid role) and got the following error message


Error: Cannot get property 'pid' on null object

java.lang.NullPointerException: Cannot get property 'pid' on null object
at com.onresolve.jira.groovy.user.FormField.getFormValue(FormField.groovy:168)
at com.onresolve.jira.groovy.user.FieldBehaviours.getIssueContext(FieldBehaviours.groovy:182)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


251 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you