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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

Is there any solution here please? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

513 views 3 18
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