Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,022
Community Members
 
Community Events
184
Community Groups

Script Runner Transition parent issue based on linkedissues

We are trying to get a Feature to automatically transition to 'In Progress', when one or all of the linked issues are also transitioned.

1 answer

Hi Karl, 

Assuming that the Feature should transition into In Progress status when the linked issue transitions from [To Do - In Progress], you may set up a Custom script post-function at this transition step.

There's a sample script in the Adaptavist Library that you may adapt to your use case: Transition an Issue using Issue Input Parameters

I modified it to fit your requirements, maybe not exactly but you may try this out. Also, I'm unsure if your issue can have multiple Features linked to/from it. However, this script takes that into consideration. 

You can test this script in the Script Console & change it up as needed:

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.issueLinkManager
def workflowManager = ComponentAccessor.workflowManager
def issueService = ComponentAccessor.issueService
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// test issue - remove the following line when implementing post-function script
//def issue = ComponentAccessor.issueManager.getIssueObject('TEST-1')

// the name of action used to transition Feature(s)
final actionName = 'In Progress'

// the corresponding workflow id
def actionId = workflowManager.getWorkflow(issue).allActions.findByName(actionName)?.id
log.warn "actionId: " + actionId

// the name of the issue link type (taking into account the link direction - inward/outward)
final issueLinkName = 'Relates'

// if it's a Feature that's transitioning, don't run this script
if (issue.issueType.name == 'Feature') {
return
}

// find the Feature(s) linked to/from this issue
def featureInward = issueLinkManager.getInwardLinks(issue.id).findAll { it.issueLinkType.name == issueLinkName }?.sourceObject
def featureOutward = issueLinkManager.getOutwardLinks(issue.id).findAll { it.issueLinkType.name == issueLinkName }?.destinationObject
def features = featureInward + featureOutward
log.warn "featureInward: " + featureInward
log.warn "featureOutward: " + featureOutward
log.warn "features: " + features

features.each { feature ->

def issueInputParameters = issueService.newIssueInputParameters()

def transitionValidationResult = issueService.validateTransition(user, feature?.id, actionId, issueInputParameters)
assert transitionValidationResult.isValid(): transitionValidationResult.errorCollection

def transitionResult = issueService.transition(user, transitionValidationResult)
assert transitionResult.isValid(): transitionResult.errorCollection
}

I hope that this helps!

If this response has answered your question, please do mark it as Accepted to make it easier for other users to discover potential solutions to their questions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events