Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner Behavior - If status any of [X, Y, Z], make read-only and display error


Trying to pick ScriptRunner back up for the organization and I'm running into some problems. Trying to read the issue status and make a field read-only... but I want to tell users why it's read-only, hence using a script rather than the OOTB read-only marker.

I've read almost every community article that mentions this, and even did a direct copy/paste from ... It either enforces ALL the time or NONE of the time. The same is true of the in-line edit... It's always locked, no matter what group I put in there.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.config.StatusManager
StatusManager statusManager = ComponentAccessor.getComponentOfType(StatusManager.class)

// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get the changed field
def exampleField = getFieldById(getFieldChanged())

if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find { == "UI-fragment-users" }) {
} else {

if (statusManager.getStatuses()*.getName() != ["To Do", "Analysis", "Intake Agenda", "Intake Meeting", "Prioritization"]) {
exampleField.setError("To maintain data integrity, this field is locked for edits after Prioritization.")
} else {


I've also tried 





But I can't seem to get it to work.

1 answer

Hi Lacey

If you are using

def exampleField = getFieldById(getFieldChanged())

then you most likely have this script applied to a field directly within the behaviour configuration.

What field is this "exampleField"?

Generally, the status of an issue does not change while in the form window that behaviours work on, so it does not really make sense to have this script on a field and it should really be in the behaviour initialiser script area.

You could try a script like this as an initialiser.

def myField = getFieldByName("TextFieldB")

// if there is no underlyingIssue then you are on the create screen and there is nothing to get the status fro,

def currentStatus =
def testStatusList = ["In Progress", "Done"]

if(currentStatus in testStatusList){
log.warn("status ${currentStatus} found in ${testStatusList}")
myField.setDescription("To maintain data integrity, this field is locked for edits after Prioritization.")



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

173 views 3 14
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you