I want to write a groovy Script in which, on certain transition of issue type 1 which follows some workflow, when state changes from state 1 to state 2 then linked issue with that ticket should move its from state 1 to state 2 which follows other workflow say workflow 2.
Can any body help me out with this?
You could search the forum. There have been several questions on this matter:
I'v been trying to do the same and ended up with sth. like this. Don't know if it's good but bascially transforemd existing scripts (I'm using Jamies Script Runner Plugin BTW)
// package com.test.transitionSubtask import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor def componentManager = componentManager.getInstance() def issueLinkManager = componentManager.getIssueLinkManager() import org.apache.log4j.Category import com.atlassian.jira.issue.comments.CommentManager import com.opensymphony.workflow.WorkflowContext import com.atlassian.jira.workflow.WorkflowTransitionUtil; import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl; import com.atlassian.jira.util.JiraUtils; def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") log.setLevel(org.apache.log4j.Level.DEBUG) log.debug "debug statements" log.debug "Hello" String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller(); WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class ); issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink -> if (issueLink.issueLinkType.name == "Blocks") { log.debug ("Linktyp: " + issueLink.issueLinkType.name) log.debug ("Status parent: " + issueLink.destinationObject.statusObject.name) log.debug ("ID parent: " + issueLink.destinationObject.getId()) log.debug ("Schlüssel Verlinkung: " + issueLink.destinationObject.getKey()) log.debug ("Lösung Verlinkung: " + issueLink.destinationObject.getResolutionObject().getName()) // Nur wenn bestimmte Lösung if (issueLink.destinationObject.getResolutionObject().getName() == "Fixed"){ // Transition einleiten workflowTransitionUtil.setIssue(issueLink.getDestinationObject()); workflowTransitionUtil.setUsername(currentUser); workflowTransitionUtil.setAction (3) // 5 == RESOLVE ISSUE // Add a comment so people have a clue why the child has been closed CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class); String comment = "*Resolving* as a result of the *Resolve* action being applied to the parent."; commentManager.create(issueLink.getDestinationObject(), currentUser, comment, true); // validate and transition issue workflowTransitionUtil.validate(); workflowTransitionUtil.progress(); } } else {log.debug("Hello CCCCCCCC")} }
Thanks for your answer, In my case I have installed Query Custom field plugin, which is a custom field which brings issues from other issue type, so i want to first link this issue and then perform the transition so can anybody help me out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Is the above script working for transitioning linked issues.
Thanks,
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Because I also want to implement it. If it works then please anyone tell me how and where to use this groovy script.
Thanks,
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Darapu Rajesh Babu, you'll need a script runner plugin, the paid one will save you a lot of time with built in functionality. In the workflow editor you can add a custom script post function that runs this. It may need some tweaking but I'm about to find out and I'll post what I ended up with
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo @Christian Czaia,
dein Script funktioniert auch wenn zwischen zwei Tickets ein klassischer Link besteht oder nur bei einem Parent+Subtask?
Grüße
Toni
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can also configure this use case with the Workflow Essentials Plugin and don't need to write a script for it.
Regards,
Joerg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.