I have 30+ subtask types and i would like to restrict with behaviours which subtask issuetypes will be shown on the create subtask screen to the user depending on the type of the father issue.
When i tried to get the underlyingIssue object (of which i only need the issuetype) on behaviour i get a null object and after 4 hours trying different approaches i surrender.
I tried already to get the issueKey showed on the url but couldn't get to get the propper one, as the request url i got is from the scriptrunner servlet, not something like https://myJiraUrl/browse/myTaskID
Trying to get the issueType field only returns me the current value of the subtask selected, the same as the issueContext.
Is there any way to do this?
The script i'm using to do the changes is this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)
def availableIssueTypes = []
availableIssueTypes.addAll(allIssueTypes.findAll { it.isSubTask()==false})//We add all the issuetypes that are not a subtask
//If parent issue is of type X then the subtasks will be the next ones
availableIssueTypes.addAll(allIssueTypes.findAll { it.id in [ "10213", "10210", "10208", "10207"] })
issueTypeField.setFieldOptions(availableIssueTypes)