Hi Team,
I need to change the "Issue Type" based on the custom "Cascading List" field. The code I am using is working correctly. When I change the custom field value to A - A1, the issue type also changes to A. However, the second value of the custom field, A1, is changing back to "None" instead of staying at A1. Is there a mistake in the script?
I utilized script runner behavior and server script.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
def issueType = getFieldById(ISSUE_TYPE)
def cascadecustomField = getFieldByName("Cascading Custom Field")
def selectedOptions = cascadecustomField.getValue() as Map
def ParentOption = selectedOptions.get(0).toString()
def ChildOption = selectedOptions.get(1).toString()
if(ParentOption == "A" && ChildOption == "A1")
{
issueType.setFormValue('B')
}
if(ParentOption == "B" && ChildOption == "B1")
{
issueType.setFormValue('B')
}