We are preparing to upgrade from Jira Server, which involves going through the Behaviors of Jira Scriptrunner and making sure we're extracting fields via FieldName, rather than using their custom IDs.
This is the original code to populate a dropdown menu:
fieldToHide = getFieldById("customfield_10600")
def customField = customFieldManager.getCustomFieldObject("customfield_10600")
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {it.value in ['FTP','Physical Media']}.collectEntries {[(it.optionId.toString()): it.value]}
fieldToHide.setFieldOptions(["-1": "None"] + optionsMap)
This is the version that I'm trying to implement:
def getDeliveryMethodField = getFieldByName("Delivery Method")
def deliveryMethodFieldId = getDeliveryMethodField.FieldId
fieldToHide = getFieldByName("Delivery Method")
def customField = customFieldManager.getCustomFieldObject(deliveryMethodFieldId )
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {it.value in ['FTP','Physical Media']}.collectEntries {[(it.optionId.toString()): it.value]}
fieldToHide.setFieldOptions(["-1": "None"] + optionsMap)
This new code breaks the menu so that it doesn't populate correctly when the code is run, but I don't understand why. If I'm extracting the fieldId of the target, and using that field to target and build the list... shouldn't this work?
Hi,
The fieldId methode is returning a string but the getCustomFieldObject wait for a long parameter. So you need to make the conversion
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.