Through a workflow post function I am trying to create / clone a new ticket while linking it to ticket number mentioned in a custom field.
We have both the JMWE and Scriptrunner plugin.
I've tried to accomplish this with the "Create / Clone issue(s) (JMWE app)" post function and I've added the script below in the "Post-creation script" section. The ticket get's created fine but there's no link set.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def issueManager = ComponentAccessor.getIssueManager()
def key = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11201")
def cFieldValue = issue.getCustomFieldValue(key)
doAfterCreate = {
def issueToLinkTo = issueManager.getIssueByCurrentKey("cFieldValue")
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)
}
}
Hello @Atlassian TMG!
I understand you want to link the ticket, entered in customfield_11201, to the new ticket created using Create/Clone Issue(s) JMWE post-function.
What's the type of customfield_11201? Will users manually enter an issuekey in this field?
Regards,
Suprija | Appfire
Hi @Suprija Sirikonda _Appfire_
Thank you for the fast reply. This field is a "Single Issue Picker" but I've also tried to see if it works with a "text field (single line)" but it doesn't work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Atlassian TMG,
If the field is of type "Single Issue Picker", add the below script in "Post-creation script" of the JMWE Create/Clone issue(s) post-function:
if(issue.get("customfield_11201"))
newIssue.linkIssue("is duplicated by",issue.get("customfield_11201"))
Replace
I hope this helps!
Regards,
Suprija | appfire
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.