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!