Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Create ticket with link from custom field value

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)
}
}

1 answer

1 accepted

1 vote
Answer accepted
Suprija Sirikonda _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 12, 2023

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.

Suprija Sirikonda _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 12, 2023

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

  • 11201 with ID of the "Single Issue Picker" field
  • is duplicated by with the desired link name.

I hope this helps!

Regards,

Suprija | appfire

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events