Scriptrunner Behaviour on Create Issue to pre-populate customfield based on Epic's status

Rob Berube March 20, 2018

Hello,

I'm trying to create a behaviour using Scriptrunner so that when creating a new issue within an epic, that the issue being created takes the epic's status and places it within a custom select list field. 

I'm able to do most of this using the script provided within the documentation but I am having a hell of a time trying to get the Epic's status and passing it to the select list.

Any help would be greatly appreciated.

Here's the code I took from the docs but I cannot figure out how to get the Epic Link's custom field value for the life of me.

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*

if (getActionName() != "Create Issue") {
return // not the initial action, so don't set default values
}


//NEED TO GET THE Status of the Epic in the Epic Link field. no dice :(


// set a select list value -- also same for radio buttons
def faveFruitFld = getFieldByName("Phase (test)")
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(faveFruitFld.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "In Development" }
faveFruitFld.setFormValue(optionToSelect.optionId)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events