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

Get the Issue Key for an Issue in a Jira Behavior

Daniel H_ Fisher March 5, 2024

1. I am writing a server-side script in Behaviors for one of my custom fields.

2. The script sends an email to a user

3. The script works in all ways except:

While all my variables get injected into the body of the email, the issue key shows as "null".

How do I get Jira to incorporate the issue key into a variable that I can use in my script.

getIssue.key() doesn't work

getfieldbyname("key") doesn't work

def curKey = getFieldByName("Key")
def issue = ComponentAccessor.getIssueManager().getIssueObject("curKey")

Doesn't work

How can I load an issue's key into a variable?



1 answer

0 votes
Uday Kiran Bhaviri
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.
March 5, 2024

You can use underlyingissue this gives you the the current issue object and it's properties.



Daniel H_ Fisher March 25, 2024

Would it be possible for you to provide a generic example of this? Which import do I need? What type of variable should I declare? A working example would be extremely helpful.

For example, I've tried using your suggeston as follows, without success:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject(underlyingIssue.key)
return issue

Suggest an answer

Log in or Sign up to answer
Site Admin
AUG Leaders

Atlassian Community Events