How to set Issue ID custom field value with groovy script

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

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

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.

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

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

Is there any solution here please? 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

243 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you