Hello, everyone.
I have some Epic and Cascading select field named "Client\Contract" in it with value.
When I create issue and choose Epic Link I need this value been copied to creating form from Epic.
I tried many variants but no result. Maximum I got ID's of needed options and println them to description - it works, but I can't put them on my Cascading select.
Even hardcoded values didn't work. Logs are empty.
Here my server-side script for Epic Link field. Initializer is empty
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.Option
try {
def epic = getFieldByName("Epic Link").getFormValue().getAt("key").toString()
MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject(epic)
def CC = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12902L)
if (issue != null) {
def epicCC = issue.getCustomFieldValue(CC)
def parentValue = epicCC.getAt(null).toString()
def childValue = epicCC.getAt("1").toString()
def CCC = getFieldById("customfield_12902")
def fieldConfig = CC.getRelevantConfig(issue)
def options = ComponentAccessor.getOptionsManager().getOptions(fieldConfig)
for (Option env in options.getRootOptions()) {
if (env.toString() == parentValue) {
def childOptions = env.getChildOptions()
long parenv = env.optionId
long chenv
for (childOption in childOptions){
if (childOption.findAll {it.toString() == childValue}) {
println childOption.optionId
chenv = childOption.optionId
}
}
def desc = getFieldById("description")
desc.setFormValue([parenv, chenv])
CCC.setFormValue([parenv, chenv])
}
}
}
} catch (Exception ex) {
println ex.getStackTrace()
}
What am I doing wrong?