ScriptRunner old project key of moved issue out of the work log

Tobias April 6, 2021

Hello together, 

we created a project which is used to move unused issues into it because we don't want to grant the right to delete issues for everyone. 

The current problem we have is that we have to get the old issue key from the previous project to see where the issue comes from. We want to solve this with a scripted field which sets the old project key.

I havent seen a functionality to extract the old project key over the work log. 

Maybe someone can help here.

Thank you guys in advance :)

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2021

The IssueManager has a getAllIssueKeys() method that makes this pretty easy.

You could create a scripted field called "Previous Issue Keys"

And add this script:

import com.atlassian.jira.component.ComponentAccessor
def issueManager= ComponentAccessor.issueManager
def allKeys = issueManager.getAllIssueKeys(issue.id)
return allKeys.findAll{it != issue.key}.join(', ')

If you really want just the project keys, you can use this as the last line:

return allKeys.findAll{it != issue.key}.collect{it.split('-')[0]}.join(', ')
TAGS
AUG Leaders

Atlassian Community Events