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

Script Runner CreateIssueLink - remote User

landrzej June 9, 2015

Hello there ,

For a few days I am trying do make post function with Sript Runner that will make a link based on issues defined in CF.

I am almost there but i cant get proper type into the remoteUser variable.

Here is the code:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.crowd.embedded.api.User
def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager() 
def issueManager = componentManager.getIssueManager() 
def customFieldManager = componentManager.getCustomFieldManager()
def jiraAuthContext = componentManager.getJiraAuthenticationContext()
def long tpIssueLinkType = 10450
def MutableIssue cfIssue 
def User currentUser = jiraAuthContext.getUser().getDirectoryUser()
CustomField customField = customFieldManager.getCustomFieldObject(13618)
issue.getCustomFieldValue(customField).each {
    iscr -> 
    cfIssue = issueManager.getIssueObject(iscr)
   
    createIssueLink(cfIssue.getId(),issue.getId(),tpIssueLinkType,1L,currentUser)
    }

With this i get:

No signature of method: 
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.createIssueLink() is 
applicable for argument types: (java.lang.Long, java.lang.Long, 
java.lang.Long, java.lang.Long, 
com.atlassian.jira.user.BridgedDirectoryUser) values: [131727, 132022, 
10450, 1, MPokorsk:10105]

 

and if I change

def User currentUser = jiraAuthContext.getUser().getDirectoryUser()

to

currentUser = jiraAuthContext.getUser()

i get

No signature of method: 
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.createIssueLink() is 
applicable for argument types: (java.lang.Long, java.lang.Long, 
java.lang.Long, java.lang.Long, 
com.atlassian.jira.user.DelegatingApplicationUser) values: [131727, 
132022, 10450, 1, MPokorsk(mpokorsk)]

 

How to get proper type for remoteUser ??

void createIssueLink(Long sourceIssueId,
                   Long destinationIssueId,
                   Long issueLinkTypeId,
                   Long sequence,
                   com.atlassian.crowd.embedded.api.User remoteUser)

 

Could You help me with this ?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Aleksandr Serebriakov January 3, 2018

 I hope I am not too late :D

I was looking almost for the same thing - is how to get that remote user, but a with a new method because the old is deprecated. So there are two ways to get that remote user.

The old one (Deprecated Since v6.0)

def remoteUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

 And the new one

def remoteUser = ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser()

  

0 votes
landrzej June 21, 2015

bump

0 votes
landrzej June 14, 2015

Anyone can help me here please ?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events