Behaviours Plug-in - Setting default value on custom field?

We added 2 behaviours scripts to pre-populate a custom field (single select list) with a default value. The first script works, however, the second one listed does not work (using different custom field, different value). Can someone please help?



// set a select list value -- also same for radio buttons

def PCRT = getFieldByName("Price Change Request Type")

def PCRToptionsManager = ComponentAccessor.getOptionsManager()

def PCRTcustomFieldManager = ComponentAccessor.getCustomFieldManager()

def customField = PCRTcustomFieldManager.getCustomFieldObject(PCRT.getFieldId())

def PCRTconfig = customField.getRelevantConfig(getIssueContext())

def PCRToptions = PCRToptionsManager.getOptions(PCRTconfig)

def PCRToptionToSelect = PCRToptions.find { it.value == "Promotion and Reversal" }




// set a select list value

def RT = getFieldByName("Request Type")

def RToptionsManager = ComponentAccessor.getOptionsManager()

def RTcustomFieldManager = ComponentAccessor.getCustomFieldManager()

def customField = RTcustomFieldManager.getCustomFieldObject(RT.getFieldId())

def RTconfig = customField.getRelevantConfig(getIssueContext())

def RToptions = RToptionsManager.getOptions(RTconfig)

def RToptionToSelect = RToptions.find { it.value == "Landing Page Creation" }



We tried switching out the second script with the custom field ID to see if that helps, but still does not work. Does anyone have any suggestions?


Oddly, we discovered that when mapping to another issue type/project it works. However, when both are mapped to the same project/issue type only the first script works.



2 answers

1 accepted

1 vote
Answer accepted

Hi Robert,

Could you please provide some screenshots of here of how you have configured your behaviours as well as what version of JIRA and Script Runner you are using.


I have taken your code above and tested it in two select list fields which I created using the configuration shown in the screenshot below.



This worked correctly for me and shows the default values when I open the create issue screen as shown in the screenshot below.

image2016-1-21 16:50:36.png

I configured these behaviours using JIRA 6.4.12 and Script Runner

I hope this helps



Hi Kristian,

Thanks very much for your response! We were able to workaround this issue by just using the JIRA contexts in the custom field configurations to set different defaults per project/issue type.

Really appreciate you trying to reproduce this though. I did notice a major difference in your screenshot, versus what I had in my behaviours config. Instead of Field: Request Type, I noticed mine has Initialiser Function. We also had 2 separate behaviours scripts for each. I wonder if one of these 2 differences was the reason we couldn't get it to work.


Screen Shot 01-21-16 at 01.42 PM.PNG


FYI - we're running JIRA 6.3.13 and ScriptRunner 3.1.4


Thanks again,


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


204 views 0 5
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