Hello everybody,
I am updating my company workflows. I have two projects, Customer Support and Logistics, with respective issue type and workflow. I would like that a transition from an issue in the Support workflow create an issue in the Logistics workflow AND transition it to the correct status.
For example :
Cloning the issue is fine, with Scriptrunner has this function exists and does not need mastering scripting. However, I do not know how to create this event as all the documentation I found on custom events are related to emails or other irrelevant updates.
Do you have suggestion on how to articulate this mechanism?
So you need a post-function that creates a linked issue in another project, and fast-tracks the created issue to a selected status?
Yes. I tried to do it in one step from the scriptrunner "Clone issue -> Additional issue action" table but could not make/find a functionnal script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Give me a sec :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issueService = ComponentAccessor.issueService
def issueLinkService = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager
def user = userManager.getUserByName("admin")
def issueInputParameters = new issueInputParameters()
def createdIssue
// Create new issue.
issueInputParameters.setSummary("Something")
issueInputParameters.setProjectId(10001)
issueInputParameters.setIssueTypeId("10010")
//issueInputParameters.addCustomFieldValue("customfield_<id>", "Value") //If you wanna add custom field values.
def validationCreateResult = issueService.validateCreate(user, issueInputParameters)
if (validationResult.isValid()) {
createdIssue = issueService.create(user, validationCreateResult)
} else {
log.info("Something")
}
//Link created issue to parent.
def issueLinkType = 10003 //Id of the type of link ex. Relates, linked etc.
issueLinkManager.createIssueLink(createdIssue.id, issue.id, issueLinkType, 1, user)
//Transition created issue.
def actionId = 101 //Change this to whatever workflow transition Id you wanna use.
def validationTransistionResult = issueService.validateTransition(user, createdIssue.id, actionId, new issueInputParameters())
if (validationTransistionResult.isValid()) {
issueService.transition(user, validationTransistionResult)
} else {
log.info("Something")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me know if you have any questions or problems! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I run it in the Script console I am unable to resolve class issueInputParameter.
Also, as the creation and linking actions are already built in, it would be nice to only have a listener doing the transition or even in the script console from the "clone and link" function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, my fault. This works in my script console :)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.issue.link.IssueLinkService
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issueService = ComponentAccessor.issueService
def issueLinkManager = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager
def user = userManager.getUserByName("admin")
def issueInputParameters = issueService.newIssueInputParameters()
Issue createdIssue
// Create new issue.
issueInputParameters.setSummary("Something")
issueInputParameters.setProjectId(10200)
issueInputParameters.setIssueTypeId("10001")
//issueInputParameters.addCustomFieldValue("customfield_<id>", "Value") //If you wanna add custom field values.
def validationCreateResult = issueService.validateCreate(user, issueInputParameters)
if (validationCreateResult.isValid()) {
createdIssue = issueService.create(user, validationCreateResult).getIssue()
} else {
log.info("Something")
}
//Link created issue to parent.
def issueLinkType = 10003 //Id of the type of link ex. Relates, linked etc.
issueLinkManager.createIssueLink(createdIssue.id, issue.id, issueLinkType, 1, user)
//Transition created issue.
def actionId = 891 //Change this to whatever workflow transition Id you wanna use.
def validationTransistionResult = issueService.validateTransition(user, createdIssue.id, actionId, issueService.newIssueInputParameters())
if (validationTransistionResult.isValid()) {
issueService.transition(user, validationTransistionResult)
} else {
log.info("Something")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry..
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.issue.link.IssueLinkService
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issueService = ComponentAccessor.issueService
def issueLinkManager = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager
def user = userManager.getUserByName("admin")
def issueInputParameters = issueService.newIssueInputParameters()
Issue createdIssue
// Create new issue.
issueInputParameters.setSummary("Something")
issueInputParameters.setProjectId(10200)
issueInputParameters.setIssueTypeId("10001")
//issueInputParameters.addCustomFieldValue("customfield_<id>", "Value") //If you wanna add custom field values.
def validationCreateResult = issueService.validateCreate(user, issueInputParameters)
if (validationCreateResult.isValid()) {
createdIssue = issueService.create(user, validationCreateResult).getIssue()
} else {
log.info("Something")
}
//Link created issue to parent.
def issueLinkType = 10003 //Id of the type of link ex. Relates, linked etc.
issueLinkManager.createIssueLink(createdIssue.id, issue.id, issueLinkType, 1, user)
//Transition created issue.
def actionId = 891 //Change this to whatever workflow transition Id you wanna use.
def validationTransistionResult = issueService.validateTransition(user, createdIssue.id, actionId, issueService.newIssueInputParameters())
if (validationTransistionResult.isValid()) {
issueService.transition(user, validationTransistionResult)
} else {
log.info("Something")
}
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.