How to obtain a fields id

Janine Roe April 11, 2012

Is there a way to get the id of a jira field? (Specifically the Description field). We are trying to move the data from a custom field we created to a jira field. We installed Script Runner, but when we go to use the "Custom Field Move" build in script, we don't know the id of the Description field, we can find the id of the custom field but not any of the Jira built in fields. Is it possible to move data from a custom created field to a Jira field via Script Runner? Or if not, can anyone recommend how to do this?

4 answers

1 accepted

1 vote
Answer accepted
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.
April 11, 2012

I think you are talking about the Copy Custom Field Values built-in script? If so it doesn't support copying to or from system fields. There should be dropdowns with the possible fields, if it's not in there it's not supported. Sounds like it could be useful though.

You could write your own script...

Janine Roe April 11, 2012

Jamie, Yes, I am talking about the Copy Custom Field Values script. I am quite new to coding into Jira. I don't have access to the server Jira is on so wouldn't be able to put a library or something that I created. I would like to be able to use the Script Runner utility to do what I want. Which is start with the existing code tweek it to do what I want by referring to the JIRA API links that Jobin and Dieter referenced. How would I do that? I can see the source code of this script, but I would need to spend time testing it before running it. Is there a way to do this? Forgive me if this is a way-out-there question. I just don't have access to the jira server our instance is on, but I do have admin access to it.

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.
April 11, 2012

Hi - for this type of script you don't need server access, because you can paste what you need in the script runner admin panel.

You won't need 90% of the code in that script, it's all to support the optionality and different types.

However you should test on a local instance... it's easy enough to run one. I would just paste out what you need from that script, rather than worry about having a GUI for it. I'm sure there's an example somewhere, can't find it right now.

Janine Roe April 17, 2012

So this question was spawned into this answer:

https://answers.atlassian.com/questions/48586/set-jira-issue-field-to-the-value-of-a-custom-field

I did get a solution to move the contents of a custom field to a standard Jira field using Script Runners script admin panel. Thanks for the tips Jamie. Great plug-in!

5 votes
Jobin Kuruvilla [Adaptavist]
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.
April 11, 2012

Look at IssueFieldConstants class to get the id of standard fields.

0 votes
Janine Roe April 17, 2012

So this question was spawned into this answer:

https://answers.atlassian.com/questions/48586/set-jira-issue-field-to-the-value-of-a-custom-field

I did get a solution to move the contents of a custom field to a standard Jira field using Script Runners script admin panel. Great plug-in!

0 votes
Dieter
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.
April 11, 2012
In a post function groovy script you can use all the setter methods described at http://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/MutableIssue.html to update Jira system fields, e.g. use issue.setDescription("my description") to update the Description. Just make sure, your script is called *before* the "update change history ..." post function

Suggest an answer

Log in or Sign up to answer