i tried the following code but seems
ComponentManager.getInstance().getSubTaskManager(); is not supported in the jira version that Iam using and is saying that method does not exist. below is the code:
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
def myIssue = event.issue
if (myIssue.getIssueType().getName() == "Story"){
if(myIssue.getStatus().getName() == "In Progress"){
SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
Collection subTasks = myIssue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
}
}
}
}
any leeds reg the same???
Try like this
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def myIssue = event.issue
if (myIssue.getIssueType().getName() == "Story"){
if(myIssue.getStatus().getName() == "In Progress"){
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection subTasks = myIssue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is your Jira version?
If it's 7.x then to get and instance of SubTaskManager try this:
import com.atlassian.jira.component.ComponentAccessor
def subTaskManager = ComponentAccessor.getSubTaskManager()
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.
hey @Alexey Matveev @Ivan Tovbin i tried this..and I had to change the status of subtask to done.
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection subTasks = myIssue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
if(it.getIssueType() == "Sub-task"){
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue(it); ---------------------------------error
String subTaskStatus = it.getStatus().getName().toString()
if(!(subTaskStatus.equals("Done"))){
workflowTransitionUtil.setAction(91);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
}
}
it shows error in this line workflowTransitionUtil.setIssue(it); saying cannot find matching method..any leads on this..I have done thise before in many cases but facing error in this line seems strange..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code must be like this
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection<Issue> subTasks = myIssue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
if(it.getIssueType() == "Sub-task"){
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue((MutableIssue) it);
String subTaskStatus = it.getStatus().getName().toString()
if(!(subTaskStatus.equals("Done"))){
workflowTransitionUtil.setAction(91);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
}
}
the myIssue variable must be of MutableIssue type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Alexey Matveev I tried using this code, but seems the getIssueType() method is not working..is there any other alternative instead of getIssueType(). can I use getIssueType.getName()??? I need to check if the issue is a Story first and later if that Story issue has child sub task issues...any leads on this?
def myIssue = event.issue
if (myIssue.getIssueType() == "Story"){
if(myIssue.getStatus().getName() == "In Progress"){
// UserMessageUtil.success(""+event)
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection<Issue> subTasks = myIssue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
if(it.getIssueType() == "Sub-task"){
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue((MutableIssue) it);
String subTaskStatus = it.getStatus().getName().toString()
if(!(subTaskStatus.equals("Done"))){
workflowTransitionUtil.setAction(91);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should learn how to search the Jira Java Api. If you find the Issue class, then you will see, that issue.getIssueType returns IssueType object and that is why you are completly right you have to use
it.getIssueType().getName()
If you are not sure about any value in your script, you can use
log.error(variableName)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.