Scriptrunner Behaviour not to run on Create Issue screen Edited

Use case: The customer wants a number of fields set to read-only when issues have certain statuses.

My solution: I have created a Scriptrunner Behaviour with an Initialiser script as follows:

if (getAction()?.id == 1) { //Do not run script on Create action
  log.warn('ACTION = CREATE')

def lockStatuses = ['status1','status2','status3'] //Statuses where fields should be read-only
def issueStatus = //Status of the undelying issue
if (!lockStatuses.contains(issueStatus)) {

else {
  def lockFields = ['customField1','customField2','customField3'] //Fields that should be set to read-only

  lockFields.each { lockField ->

This works fine on Edit- and Transition screens.

My problem: If I first view an issue that has one of the above statuses, and then press the "Create" button, the above fields is being set to read only on the Create screen, despite the first "if" in the script.
If I Cancel out of the Create screen and press the "Create" button once again, the fields are now writable. The issue seems to only occur directly after opening av issue, or after previewing it on boards.

Do anyone have suggestions on what I should try next?

1 answer

Hi Martin,

Try switching out your first if statement for the following:

if (getActionName() in ["Create Issue", "Create"]) {

 I've found when doing this you need to take into account "Create" and "Create Issue"

Hope this helps!


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,652 views 2 7
Join discussion

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