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
https://community.atlassian.com/t5/Jira-questions/issueService-transition-does-not-update-status-of-issue/qaq-p/782979
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.IssueServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.config.SubTaskManagerimport com.atlassian.jira.issue.IssueInputParametersimport com.atlassian.jira.issue.MutableIssueimport org.apache.log4j.Categoryimport static org.apache.log4j.Level.DEBUGimport com.opensymphony.workflow.WorkflowContextimport com.atlassian.jira.workflow.WorkflowTransitionUtil;import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;import com.atlassian.jira.util.JiraUtils;import com.atlassian.jira.issue.link.IssueLinkManagerimport com.atlassian.jira.issue.link.IssueLinkTypeManagerimport com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.web.bean.PagerFilterdef 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 = nulldef 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.
It looks like you're new here. Sign in or register to get started.