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.
Hi @Lakshmi CH
For your requirement, you should modify your code to something like:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours behaviours
def cascade = getFieldById(fieldChanged)
def cascadeValue = cascade.value
def issueType = getFieldById(ISSUE_TYPE)
def currentValue = []
if (cascadeValue == ['Story', 'Story 1']) {
issueType.setFormValue('Story')
currentValue = ['Story', 'Story 1']
} else if (cascadeValue == ['Bug', 'Bug 1']) {
issueType.setFormValue('Bug')
currentValue = ['Bug', 'Bug 1']
}
if (currentValue.size() > 0) {
cascade.setFormValue(currentValue)
}
However, this is not an approach I would recommend. The reason is once the issue type has changed according to the option selected from the Cascading List, it will not be able to change again. You will need to create an issue from scratch.
It would be best to only set the Parent value of the cascading list as it is currently working.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Thank you @Ram Kumar Aravindakshan _Adaptavist_ for correcting my script. It's working; expected now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
The issue type doesn't change if the child value is "None" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lakshmi CH
The approach you are taking is wrong.
If you want to set the condition for only the Parent list and the Child list being None, all you have to do is:-
if (cascadeValue == ['Story']) {
issueType.setFormValue('Story')
}
I hope this help answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its working @Ram Kumar Aravindakshan _Adaptavist_
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.