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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

When is a Jira Issue assigned an issue key?

I'm attempting to write a ScriptRunner Post Function on the "Created" transition for an issue, that will link the newly created issue to an existing Epic. 

 

I'm running into issues though, as the issue key doesn't seem to be assigned yet during the Post Function of the "created" transition.

 

Here is the code:

 

import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import configuration.JiraConfiguration
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.user.ApplicationUser

 

def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def availableIssueLinkTypes = issueLinkTypeManager.issueLinkTypes
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
def linkType = availableIssueLinkTypes.findByName("Depends")


issueLinkManager.createIssueLink("SEC-49" ,issue.getKey(), linkType.id, 1L, user)

 

And here is the error I'm receiving:

groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.link.DefaultIssueLinkManager.createIssueLink() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl, null, Long, Long, com.atlassian.jira.user.DelegatingApplicationUser) values: [SEC-49, null, 10300, 1, 083673(083673)]
Possible solutions: createIssueLink(java.lang.Long, java.lang.Long, java.lang.Long, java.lang.Long, com.atlassian.jira.user.ApplicationUser)
	at ValidateSecurityFields.run(ValidateSecurityFields.groovy:63)


 

Is there a better way to accomplish this other than a Post Function on the created transition?

 

Thanks!

2 answers

You could try automation with a trigger on the create event. (either with automation for jira, or creating your own listener.)

Also the order of your post functions is important. Make sure yours is at the bottom of the list. (you might need an extra re-index after it)

0 votes
Ismael Jimoh Community Leader Dec 28, 2020

Place your script in the last position of your post function. At this point, JIRA should already have assigned an issue key. Alternatively you can also use a script listener since this fires only after issue has been created and you can use the even.issue.getKey() to get your issue key.

Regards.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,071 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you