Hi guys,
I have the following script (based on example from https://answers.atlassian.com/questions/38845277).
What I am trying to figure out, is if there is a way to have it fire only during issue create issue events – regardless of workflow. I have several workflows, and I don't want to create individual behaviours for each workflow's create issue transition.
Any tips? Below is the behaviour I have currently:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def issue = getIssueContext().getIssueTypeObject()
def issueType = issue.getName()
def radioButton = getFieldById(getFieldChanged()) // Radio Button
if (issueType == "Foobar") {
radioButton.setFormValue(optionFor(radioButton, "Yes").optionId)
} else {
radioButton.setFormValue(optionFor(radioButton, "No").optionId)
}
private Option optionFor(FormField radioButton, String value) {
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(radioButton.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == value }
optionToSelect
}Thanks for the help!