Hello,
We have a behaviour to add a message when we create a Subtask ( check if subtask type is compatible with parent issue) , just like this :
Since new release ( 5.4.1 ) this behaviour is not working anymore ( OK with release 5.2.2).
Option of this behaviour :
- Mapping all Projet / All issue types
- Behaviour settings :
- No use validator plugin
- Guide Workflow : None
- No Initialiser
- Fields :
- Issue Type :
- Optional
- Writable
- Shown
- No condition
script :
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
FormField formIssueType = getFieldById(getFieldChanged())
FormField formParentIssueId = getFieldById("parentIssueId")
Long parentIssueId = formParentIssueId.getValue() as Long
if (!parentIssueId) {
// this is not a subtask
return
}
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
def parentIssueTypeName = parentIssue.getIssueType().name
def constantsManager = ComponentAccessor.getConstantsManager()
if (parentIssueTypeName == "Project" || parentIssueTypeName == "Epic" || parentIssueTypeName == "Target" ) {
formIssueType.setHelpText("It is not allowed to create subtasks in Epic or Project or Target")
return
}
if (parentIssue.status.name == "Closed" ) {
formIssueType.setHelpText("It is not allowed to create subtasks when the parent is closed")
return
}
//add subtasks allowed on all tickets
List allowedSubtasks = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Communicate - Escalate","Conduct Meeting","Document","Report","Sub-Task"]
}.collect {
it.id
}
if (parentIssueTypeName == "Incident") {
allowedSubtasks.addAll(constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Deploy","Validate and Execute Test","Fix"]
}.collect {
it.id
})
}
// Too many condition ....
else if (parentIssueTypeName == "Service Request") {
allowedSubtasks.addAll(constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Deploy"]
}.collect {
it.id
})
}
if (allowedSubtasks.contains(formIssueType.getValue())) {
formIssueType.clearHelpText()
} else {
formIssueType.setHelpText("This is not a valid subtask type for issue type " + parentIssueTypeName +
".")
}
Hi Yoann,
We are aware of this bug and there is actually a dev issue SRJIRA-2738, please vote for it and start watching it in order to get updates regarding its status.
Apologies for any inconvenience this may caused,
Thanos
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.