Hi everyone,
I'm trying to restrict available issue types on subtask creation, based on the issue type of it's parent issue. So, for example, for the issue type "Sample", on subtask creation, I want to have only one option "Issue subtask".
So far I've implemented the following script, as an initialiser function on behaviour, and then set it to issueType field:
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
Issue parentIssue = underlyingIssue.parentObject
def constantsManager = ComponentAccessor.getConstantsManager()
def sampleIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Sample" }
if(parentIssue.getIssueType().equals(sampleIssueType)){
def issueSampleIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Issue subtask" }
// In other cases, I'll need multiple options
getFieldById(ISSUE_TYPE).with {
setFormValue(issueSampleIssueType.id)
setReadOnly(true)
}
}However, it is not working as expected (all issue types are available when I create a subtask of "Sample")
Can someone please help me on that?
Thanks in advance,