You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.