Hello
I have below requirement.
I have two projects lets say XYZ and ABC.
i create a issue in XYZ as XYZ-1 and in ABC as ABC-1
now XYZ-1 is linked with ABC-1 by causes link
The status of XYZ-1 is TO DO and ABC-1 is TO DO.
when I move the issue XYZ-1 from TO DO to IN PROGRESS,the status of the issue ABC-1 should be moved from TO DO to In progress automatically
How to achieve above with a script?Please help me
I have gone below articles https://community.atlassian.com/t5/Jira-questions/IssueService-IssueResult-transition-doesn-t-modify-the-status-of/qaq-p/430403
but could not able to solve.
thank you
Hello,
I have a similar script and wanted to share it with you. This script transitions an issue if there is a duplicate linked issue transitions. You need to change some aspects of the code, of course, like the issue link type and transition IDs. You need to change id of the transition for every transition you make and add it to the necessary transition as post function.
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Category
import static org.apache.log4j.Level.DEBUG
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.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
def issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getUserManager()
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("TEST-10")
def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def user = authenticationContext.getLoggedInUser()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def searchService = ComponentAccessor.getComponent(SearchService.class)
def jqlSearch = '(issueFunction in linkedIssuesOf("issuekey = ' + issue + '", "is duplicated by")) or (issueFunction in linkedIssuesOf("issuekey = ' + issue + '", "duplicates"))'
def parseResult = searchService.parseQuery(user, jqlSearch)
List issues = null
def workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
def userkey = user.getKey()
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}
for (int i = 0; i < issues.size(); i++) {
MutableIssue linkedissue = (MutableIssue) issues[i]
if (linkedissue.getStatusId() != 10001) {
def issueInputParameters = issueService.newIssueInputParameters()
def validationResult = issueService.validateTransition(user, linkedissue.getId(), 31, issueInputParameters)
if (validationResult.isValid() == true) {
issueService.transition(user, validationResult)
} else {
continue
}
}
}
Hope this helps.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.