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

Tobias
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.
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
PD Sheehan
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.
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