Status of the linked issue to move in progress when the main issues moves to in progress

Ramesh Penuballi September 4, 2023

Dear Team,

 

I have used the below script in groovy in post condition to modify the linked issue status to move in progress when the main issue moves to in progress.

 

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.issue.link.IssueLinkManager

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueService = ComponentAccessor.issueService

def actionId = 101 // Change this to the desired transition ID
def mainIssueKey = issue.key // Assuming this is within a post-function

def mainIssue = ComponentAccessor.issueManager.getIssueObject(mainIssueKey)
def issueLinkManager = ComponentAccessor.issueLinkManager

if (mainIssue) {

def linkedIssues = ComponentAccessor.issueLinkManager.getLinkCollection(mainIssue, currentUser).getAllIssues()
linkedIssues.each { linkedIssue ->
def transitionValidationResult = issueService.validateTransition(currentUser, linkedIssue.id, actionId, new IssueInputParametersImpl())

if (transitionValidationResult.isValid()) {
def transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (!transitionResult.isValid()) {
log.warn"successfull"
}
} else {
log.warn"unsuccessfull"
}
}
The above script modify the linked issues to in progress when its  main issue moved to in progress successfully.
But I am looking for the script to modify linked issue status to in progress which is of the linked issue type "contains". I tried to add  like below code to the above but it is not working.
if(!linkedIssue){
List<IssueLink> outwardLinks = issueLinkManager.getInwardLinks(issue.getId())
.stream()
.filter({ linkName == "contains" })
.collect(Collectors.toList())
if (outwardLinks.size() > 0) {
linkedIssue = outwardLinks.get(0).destinationObject
}
}
Any ideas to achieve the my purpose.?
Thanks and Regards,
Ramesh Penuballi

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events