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?
THIS ONE IS WORKING:
// 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" }
PCRT.setFormValue(PCRToptionToSelect.optionId)
THIS ONE IS NOT WORKING:
// 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" }
RT.setFormValue(RToptionToSelect.optionId)
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.
Thanks!
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.
config.png
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 4.1.3.4.
I hope this helps
Thanks
Kristian
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,
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.