Start progress on an issue triggered by another issue

Hi ;

There are two issues given to me , i want to make a configuration that if I start progress in one of them , the other should be started.How can i do that via Script Runner plugin? I've been digging the script post functions for the "start progress" transition for hours but i got nothing.

Need your help,tips,tricks...

Regards.

Mert.

2 answers

On Transition of the first issue, you can call a script that would look something like this:

int stepId = workflow.getLinkedStep(secondIssue.getStatusObject().getGenericValue()).getId();
StepDescriptor stepDescriptor = workflow.getDescriptor().getStep(stepId);
int savedAction = 0;
		 	
 // Find a "Start Progress" transition
 for (Iterator<ActionDescriptor> iter = stepDescriptor.getActions().iterator(); iter.hasNext();) {
       ActionDescriptor actionDescriptor = (ActionDescriptor) iter.next();
       if (actionDescriptor.getName().contains("Start Progress")) {
               savedAction = actionDescriptor.getId();
        }
}
if(savedAction != 0){
        // Add a comment so there is history of the handoff
	CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
	String comment = "*Start Progress* as a result of the *Start Progress* action being applied in $issue.key";
	commentManager.create(secondIssue, currentUser, comment, true);

	workflowTransitionUtil.setIssue(secondIssue);
        workflowTransitionUtil.setUsername(currentUser);
        Map<String, String> params = new HashMap<String, String>();
        workflowTransitionUtil.setParams(params);
        workflowTransitionUtil.setAction(savedAction);

	// validate and transition issue
	workflowTransitionUtil.validate();
	workflowTransitionUtil.progress();
}

Only improvement would probably be to use IssueService, rather than WorkflowTransitionUtil, but not a bigggie.

It was like @Nancy said. Otherwise you could set a "comment" pair in params. like :

def workflowManagerUtil = workflowTransitionUtilFactory.create()                                                                                                                                 
workflowManagerUtil.setIssue(tIssue)                                                                                                                                                             
workflowManagerUtil.setUsername(event.getUser().getName())                                                                                                                                       
workflowManagerUtil.setAction(i.getId())                                                                                                                                                         
workflowManagerUtil.setParams([comment: "Trigger by Plugin"])                                                                
workflowManagerUtil.progress()

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,950 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot