Hello everyone,
I would like to change the state of an issue when a sub-task go through its "In progress" state to "Done". One important point is that the issues belong to a workflow while all sub-task belong to a different one.
After some search on the community I tried with this code:
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
MutableIssue parent = issue.getParentObject() as MutableIssue
workflowTransitionUtil.setIssue(parent)
workflowTransitionUtil.setAction(241)
if (workflowTransitionUtil.validate()) {
workflowTransitionUtil.progress()
}
that return a simple message error like this
ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: NSJ-15, actionId: 161, file: null
Anyone can help me?
Thanks
hello,
after few tentatives I decided to use a different approach and I solved my problem.
I add the code below in case someone would to do the same thing
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.issue.MutableIssue
MutableIssue parent = issue.getParentObject() as MutableIssue
Integer actionId = 241
IssueService issueService = ComponentAccessor.getIssueService()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
TransitionOptions transitionOptions = new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()
IssueService.TransitionValidationResult result = issueService.validateTransition(currentUser,
parent.getId(),
actionId,
issueService.newIssueInputParameters(),
transitionOptions)
if (result.isValid()) {
issueService.transition(currentUser, result)
} else {
log.warn result.getErrorCollection().getErrors()
}
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.