Hi,
I'm new to Jira.
I'm trying to update the status of the sub-task if the parent task changes status to "NR".
All of the workflows have an "Not Required" (not required state).
This is what I have currently tried, however the project is not updated.
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.status.Status
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption
IssueManager im = ComponentAccessor.getIssueManager();
def GroupManager = ComponentAccessor.getGroupManager();
UserManager userManager = ComponentAccessor.getUserManager();
MutableIssue issue = im.getIssueObject("TEST-54");
long project_id = issue.getProjectId();
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def cStatus = issue.getStatus().getName();
def subIssueList = issue.getSubTaskObjects();
MutableIssue subIssue = null;
List subTaskStatus = [];
if(issue.getStatus().getName() == "Not Required"){
subIssueList.each {
it.getStatus().getName();
subIssue = im.getIssueObject(it.getKey());
subIssue.setStatus(issue.getStatus());
subTaskStatus.add(subIssue.getStatus().getName());
im.updateIssue(loggedInUser, subIssue, EventDispatchOption.DO_NOT_DISPATCH, false);
}
}
return subTaskStatus
All of the sub-tasks are show "Not Required" when printing the information in console, however they are not updated under projects.
What do I need to add to save the changes?
And is it possible to automate this for any generic issue/project/workflow?
Hi @rajey your use case can be implemented in JIRA using one of the 3-rd party add-ons available in Atlassian Marketplace for that. If you don't have a strict requirement of sticking to this Groovy Code based automation, there are other 3-rd party add-ons that can be used to implement this automation without requiring any code. One of them is "Update on Transition for Jira". Please check out this add-on and its documentation on Atlassian Marketplace.
Hope it helps!
def transitionValidate = ComponentAccessor.getIssueService().validateTransition(User, pIssue.getId(), transitionId, new IssueInputParametersImpl());
if(transitionValidate.isValid())
{
def transition = ComponentAccessor.getIssueService().transition(User, transitionValidate);
}
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.