Retrieving Issue Key with Script Field

Junaid Shah
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.
February 27, 2015

Hi,

I know how to reference fields using getCustomFieldValue("xxxx") however Im trying to retrieve the Issue Key, what reference is this under, or how would I do so in a Script Field.

 

Thank you.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 27, 2015

Scripted fields have the issue object directly available.  So you can just say issue.getKey()

Junaid Shah
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.
February 27, 2015

Hi Nic, following your issue.getKey I get this error: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: getKey for class: com.atlassian.jira.issue.IssueImpl A stacktrace has been logged.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 27, 2015

You need the braces on the end to tell it that it is a function rather than a property.

Junaid Shah
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.
February 27, 2015

Thank you!

JamieA
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.
February 27, 2015

or use: issue.key

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 27, 2015

I'm betraying my pre-script-runner-I-need-to-write-a-java-plugin background there ;-)

Tony August 20, 2019

Nick: "You need the braces on the end to tell it that it is a function rather than a property."

Can you give an example?  I'm not understanding what you mean by You need the braces on the end to tell it that it is a function rather than a property.  For example, what is "it" and where is the "end"?

${issue.getKey()}  ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 20, 2019

In this case, issue is an object, which could have properties (fields, although not quite) and functions that run and (can) return data.  getKey is a function, to which you can pass parameters in the following ().

So, no not ${getKey()}, but issue.getKey()

Tony August 20, 2019
  • Open/close parens [parentheses]: ()
  • Open/close curly braces: {}
  • Open/close [square] brackets: []

I think, when you earlier replied to Sy, you said braces I think you meant parens... :-)

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 21, 2019

Yes, I have a blind spot for those names!  (Along with another one for it/it is/its).  At least the idea was correct...

Like Tony likes this
Tony August 21, 2019

No problem .. I do too!

TAGS
AUG Leaders

Atlassian Community Events