How to get all the custom and system Issue fields (and their types) with the Java API?

Hi,

     How to get all the custom and system Issue fields (and their types) with the Java API?

Thanks!

Pablo.

1 answer

1 accepted

0 votes
Accepted answer

For customfields, iterate through customFieldManager.getCustomFieldObjects();  For each one, use getCustomFieldType() for the "type"

For the system fields, you have two problems.  First, almost all of them are they're own "type", although they may eventually store similar data to other fields.  Secondly, there's no list.  To fix both of those issues, you have to know the list of all the types and code for each of them that you want to use explicitly.  The method I remember is FieldManager.getField(IssueFieldConstants.<something> where <something> is an item from the constant list at https://docs.atlassian.com/jira/latest/index.html?com/atlassian/jira/issue/CustomFieldManager.html

Where is the API relating system fields and their issues' values? Example: If you got a 'issue.field.project' key... how could you to get the project value from an issue? Does it exist anything like API.getValue(Field field, Issue issue)??

The API provides methods for reading fields, but some fields are read differently from others. issue.get<something> works for most, but not the ones with more involved structures. Start at https://developer.atlassian.com/jiradev/api-reference and work your way down to the issue object

Nic, thanks for your help, but this is not the right answer. I got it with by using a different way.

Well, no, it *is* the right answer. But there are other ways to get to the fields, which sometimes can be better, depending on the context you are starting from. The question didn't specify a start point, so I gave the correct generic answer.

Agree, no problem in acceptong your answer as correct too. In my particular case, I used the Export to Excel All Fields approach which provides all the regular and custom fields in HTML text format.

Yes. That, of course, is absolutely *not* getting it via the API, but it will give you the list.

Hi Pablo, can share your code for custom fields ...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

336 views 0 1
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