How to set Issue ID custom field value with groovy script

Haris Becic May 18, 2017

Hi,

i have a question regarding issue ID in JIRA. I have a custom field with the name "Issue ID" and i want to set this value automatically after the issue is created. With this small script i get the issue ID but how can i set/copy this value to the "Issue ID" Custom field when the issue is created? I want to do it automatically with a Post Function.

import com.atlassian.jira.issue.Issue;
 
Issue issue  = issue
def id=issue.getId()

 

Thanks

BR 

3 answers

0 votes
Haris Becic May 22, 2017

Is there any solution here please? 

0 votes
Haris Becic May 19, 2017

As we are using "Prototype" Issue type in our company we need Issue ID (Custom Field). The procedure is following:

I create a new JIRA issue and the custom field is only on "Edit" and "View" screen. When the issue is created the "Issue ID" Field contains the ID which i can grabb with the small script above for example 33904. How can i do it with a groovy script? I want to do it as a Post Function after the issue is created. 

Thanks

0 votes
Renjith Pillai
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.
May 18, 2017

Haris, even though your question is about setting the value for the custom field, it looks like you do not need to have another field to store the id. Can you eloborate why you are doing this?

And for setting the value, the guide for Script Runner - https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html

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.
May 18, 2017

I suspect Haris is looking for an immutable issue id - one that does not change when an issue is moved. 

The database ID is ideal for that, so exposing it is probably better than generating another one.  But it's not actually that useful, as JIRA's UI does not use it in any way, you can't link to it or anything. 

The issue key, while not immutable, is still far more useful for users.

Haris Becic May 19, 2017

As we are using "Prototype" Issue type in our company we need Issue ID (Custom Field). The procedure is following:

I create a new JIRA issue and the custom field is only on "Edit" and "View" screen. When the issue is created the "Issue ID" Field contains the ID which i can grabb with the small script above for example 33904. How can i do it with a groovy script? I want to do it as a Post Function after the issue is created. 

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events