It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
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 [Adaptavist] 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)
}
}
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
@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)
}
}
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.