Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Auto transition clone issue (scriptrunner)

Sümeye Beki
Contributor
November 18, 2022

Hi everyone,

I have a situation with transitioning the original issue from cloned issues. Here is the situation:

The original issue may have one clone or more. For example I have a bug in my project but it affects a product line as well. In this case there will be a product line clone. Developers will fix this bug on the product line clone. When the bug is resolved, I want my original issue's status as resolved automatically. I implemented this to my jira instance.

But the problem is that there may be more than one product line clone. How am I suppose to block this automatic transition if there are more than one clone?  

By the way, I have JSU, JMWE and Scriptrunner plugin installed on my jira(v_8.7) instance. 

1 answer

0 votes
Vedant Kulkarni_Trundl
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 18, 2022

@Sümeye Beki , you can use the scripted listener and try something similar like the below code which will transition your original issue only when your all cloned issues are fixed/closed

def x = 
ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())?.findAll {it.issueLinkType.outward == "Cloners"}*.destinationObject?.findAll { it.status.statusCategory.name != "Complete" }


if(x.size()==0)
{

JiraWorkflow workFlow = ComponentAccessor.getWorkflowManager().getWorkflow(issue);
com.opensymphony.workflow.loader.StepDescriptor currentStep = workFlow.getLinkedStep(issue.getStatus());
List<ActionDescriptor> actions = currentStep.getActions();
for(ActionDescriptor action : actions)
{

if(action.getId() == <id>)
{

boolean result = false;
IssueService issueService = ComponentAccessor.getIssueService();
IssueService.IssueResult transResult;
IssueInputParameters issueInputParameters = new IssueInputParametersImpl();
TransitionValidationResult validationResult = issueService.validateTransition(user, issue.getId(), action.getId(), issueInputParameters);
result = validationResult.isValid();
if(result)
{
transResult = issueService.transition(user, validationResult);
}
}
}
}

Suggest an answer

Log in or Sign up to answer