Get values from linked issue ScriptRunner

I'm trying to inherit values when creating a linked issue, primarily the assignee since this can't be set in an issue collector, per Atlassian's documentation.  

I've added this into the workflow scripted post function to no avail:

import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
issueLinkManager.getOutwardLinks( {issueLink ->
    def linkedIssue = issueLink.destinationObject
    issue.assignee = linkedIssue.getAssignee()

JIRA doesn't like that and won't let me use the workflow transition on issues with that function in place.  Error says:

Property 'issueLink' not found

It seems that you have tried to perform an illegal workflow operation.


I'm open to other alternatives, but scriptRunner just seemed to be the best route without sinking more money into add-ons.  

1 answer

1 accepted

4 votes
Accepted answer

Hi Robert,

You can use a script listener that will listen for Issue Created events and use as a script the following 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

def issue = event.issue as MutableIssue

def issueService = ComponentAccessor.issueService
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueInputParameters = issueService.newIssueInputParameters()

// this is in question since there can be more than one issues linked with a different assignee each one
def assigneeToSet = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(issue)?.allIssues?.getAt(0)?.assignee

issueInputParameters.with {
    projectId = issue.projectId
    summary = issue.summary
    issueTypeId = issue.issueTypeId
    reporterId =
    assigneeId = assigneeToSet?.key

def validationResult = issueService.validateUpdate(user,, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()

def issueResult = issueService.update(user, validationResult) "Issue updated: ${issueResult.issue}"

Of course you can edit the script above to use it as a Post function.

The main question here is what is happening if you create an issue with other 2 linked issues that each has a different assignee. Whom are you going to add ? 

In the example above I assume that you will get the assignee of the first issue. 

Please let me know if this does the trick.

regards, Thanos

That appears to be working for me, Thanos.  Thank you very much.  

In regards to your question with the issue links and potentially having more than one, we're actually creating the issues from JIRA issues, using an issue collector which sets an individual link in the background so, in theory, we shouldn't ever get one with multiple links.  We're stretching the systems legs to use it for assets and their change requests.  smile 

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

5,394 views 21 17
View question

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you