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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,671
Community Members
 
Community Events
184
Community Groups

ScriptRunner: DefaultIssueLinkManager.createIssueLink does not work with DelegatingApplicationUser

Hi,

I want to create a IssueLink by a ScriptRunner Post function during the create transition of an issue.
But when calling createIssueLink(..), an MissingMethodException is thrown:

groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.issue.link.DefaultIssueLinkManager.createIssueLink() is applicable for argument types: (java.lang.Long, java.lang.Long, java.lang.Long, java.lang.Long, com.atlassian.jira.user.DelegatingApplicationUser) values: [11442, 11502, 10003, 1, glt(glt)]
Possible solutions: createIssueLink(java.lang.Long, java.lang.Long, java.lang.Long, java.lang.Long, com.atlassian.jira.user.ApplicationUser)

So it seems that createIssueLink(..) requires a ApplicationUser instead of an DelegatingApplicationUser. The documentation states that DelegatingApplicationUser implements ApplicationUser. So I am wondering why Jira throws this exception.

I use ScriptRunner v.5.2.2 and Jira v 7.6.1. My source is is:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.link.DefaultIssueLinkManager
import com.atlassian.jira.bc.issue.IssueService

def issueService = ComponentAccessor.getIssueService()        
def issueInputParameters = issueService.newIssueInputParameters()
def actIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.projectObject).find {it.name == "HW_IT_Layout"}

issueInputParameters.setIssueTypeId(actIssueType.getId())
issueInputParameters.setProjectId(issue.getProjectId())
issueInputParameters.setSummary("Summary")

def createValidationResult = issueService.validateCreate(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issueInputParameters)
def createResult = issueService.create(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), createValidationResult)    

DefaultIssueLinkManager.createIssueLink(issue.getId(), createResult.getIssue().getId(), 10000L, 1L, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser())

Has anyone am idea what is going wrong?

Thanks in advance,
    Stefan

1 answer

1 accepted

3 votes
Answer accepted
Alexey Matveev
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.
Dec 15, 2017

Try like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.link.DefaultIssueLinkManager
import com.atlassian.jira.bc.issue.IssueService

def issueService = ComponentAccessor.getIssueService()        
def issueInputParameters = issueService.newIssueInputParameters()
def actIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.projectObject).find {it.name == "HW_IT_Layout"}

issueInputParameters.setIssueTypeId(actIssueType.getId())
issueInputParameters.setProjectId(issue.getProjectId())
issueInputParameters.setSummary("Summary")

def createValidationResult = issueService.validateCreate(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issueInputParameters)
def createResult = issueService.create(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), createValidationResult)    

ComponentAccessor.getIssueLinkManager().createIssueLink(issue.getId(), issue2.getId(), 10000L, 1L, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser())

Hello Alexey,

thnaks for your hint. I only had to add

def issue2 = createResult.getIssue() 

after the line

def createResult = issueService.create(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), createValidationResult)    

Then, it worked.

Thanks,

  Stefan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events