Is there a way with scriptrunner to restrict the sub-tasks that you can create depending on the parent issue that you're creating it in?
I want to limit the sub-task options when creating under a standard issue type called "Comms" to just "Plan", "Weekly Download", "Slack", "Email", "Weekly Wrap", "The Street", "Edit", and "Write".
Referencing SRJIRA-1010, I thought this initialiser script would do the trick:
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 commsIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Comms" }
if(parentIssue.getIssueType().equals(commsIssueType)){
def subtaskSet = constantsManager.getAllIssueTypeObjects().findAll
{ it.name in ["Plan", "Weekly Download", "Slack", "Email", "Weekly Wrap", "The Street", "Edit", "Write"] }
.collectEntries{
[(it.id)]}
getFieldById("issuetype").setFieldOptions(subtaskSet)
}
But unfortunately I still see other sub-task issue types still available.