I am using jira build-in post to Clones an issue and links ,and try to link original issue with new issue,
however issue.id is null, not sure why?
Could @Thanos Batagiannis [Adaptavist] , @Jamie Echlin _ScriptRunner - The Adaptavist Group_ or some of the other Adaptavist guys please help me out here?
Hey
I think that the Do After Create actions in the documentation is what you need. There is also there an example similar to what you want to achieve.
Regards, Thanos
Thanos,
I did try code below, but got some error:
line 12 cannot find matching method.
When creating an issue A, I use the "Clone an issue and links" post function on the creation transition.
This creates a clone issue, issue B,
I want to link issue A to clone issue B, should I use sourceIssue.id or originallissue.id
Could you help me take a look?
@Thanos Batagiannis [Adaptavist]
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def issueManager = ComponentAccessor.getIssueManager()
doAfterCreate = {
def issueToLinkTo = issueManager.getIssueByCurrentKey(sourceIssue.id.toString())
def duplicateLinkTypeName = "Duplicate"
def duplicateLinkType = issueLinkTypeManager.getIssueLinkTypesByName(duplicateLinkTypeName)
if (!duplicateLinkType) {
log.warn ("Issue link type with name: ${duplicateLinkTypeName} does not exist")
} else {
issueLinkManager.createIssueLink(issue.id, issueToLinkTo.id, duplicateLinkType[0].id, 1, currentUser)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just reread your question and I am a bit confused. In the clone issue and links there is a dropdown - Issue Link Type / Direction - where you can set a link from original issue to the issue that just got created, you do not need to add any custom script ...
Did you try to make use of that dropdown and failed ?
regards, Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist]
Following are the detail:
When creating an issue A, I use post function Clone Issue and Link on creation transition. And this will create a clone issue B, then automatically link issue A to issue B.
So I add follow code in 'Clone issue and Link' - Additional issue actions:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def issueManager = ComponentAccessor.getIssueManager()
doAfterCreate = {
def issueToLinkTo = issueManager.getIssueByCurrentKey(sourceIssue.id.toString())
def duplicateLinkTypeName = "Duplicate"
def duplicateLinkType = issueLinkTypeManager.getIssueLinkTypesByName(duplicateLinkTypeName)
if (!duplicateLinkType) {
log.warn ("Issue link type with name: ${duplicateLinkTypeName} does not exist")
} else {
issueLinkManager.createIssueLink(issue.id, issueToLinkTo.id, duplicateLinkType[0].id, 1, currentUser)
}
}
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.