Hi,
I am trying to identify a cloned issue using a post-function on create step of the workflow.
If it is a clone, I will like to perform some changes in the issue(custom fields, summary, assignee)
Is it possible? Anyone knows how? I tried several variants none seems to work
Below is the clearest one, I am using scriptrunner but...not working
Any idea? This script always return something in else. The name of the link is correct, tryed uppercase, all lowercase. same result. I think I'm missing something.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
def linkManager = ComponentAccessor.getIssueLinkManager()
if (linkManager.getOutwardLinks(issue.getId()).any {IssueLink link ->
link.getIssueLinkType().getName() == "Cloners"})
{
//do something
}else{
//nothing
}
Thanks
Without looking to closely at the provided script have you made sure that this post-function is the last post-function on the create transition list? Otherwise nothing is gonna work :)
Hi Mathias
Thanks for answering - it is the last one, after fire a issue created event
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm this works in my console. I have comment out the issue I was using for testing purposes :)
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
log.setLevel(Level.INFO);
def issueLinkManager = ComponentAccessor.issueLinkManager
def issueManager = ComponentAccessor.issueManager
//def issue = issueManager.getIssueObject("SD-492")
def clonedId = 10001 //Cloned
def links = issueLinkManager.getInwardLinks(issue.id)
links.each() { linkedIssue ->
if (linkedIssue.issueLinkType.id == clonedId) {
def clonedIssue = issueManager.getIssueObject(linkedIssue.sourceId)
log.info("Watch out issue with key: ${clonedIssue} is a clone!")
}
}
Hope it helps! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mathis,
Some-how, on my end this is not working and I'm not able to see the results of
linkedIssue.issueLinkType.id
In logs will appear only workflowopperation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post a screenshot of the log and I'll take a look :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.