Is there a way to determine to whcih project a custom field belongs to?

mirek paszkowski November 2, 2017

Let's say I have 2 projects, p1 and p2.  The create issue screen for each project has customfield_1  and customfield_2 respectively.

 

GET api/2/filed returns all fields.

 

Am I correct in thinking that all fields are returned but there is no information to identify to which project the custom fields belong to?

 

To get around this, one way would be to prefix the custom field name with a project identifier when creating it?

 

3 answers

2 votes
Steven F Behnke
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.
November 2, 2017

Please don't do that. I have been paid professionally to clean up configurations like that. If you scale that sort of configuration out Jira will become very difficult to search and use.

Custom Fields are NOT for projects. You are thinking about it wrong. Custom Fields are more or less global. Use the createMeta and editMeta REST endpoints to discover which fields are in-use by a project. Using the Custom Field name is not a good idea.

0 votes
mirek paszkowski November 3, 2017

Thanks for replies.  I was thinking about this on the way home last night and came to the conclusion that custom fields are "global" to JIRA and by adding them to project screens (e.g. issue create) , they become available for use when creating an issue in the project.

 

Our application will need to create a custom field, then add it to a particular  screen for a project.  We need to associate the custom field id to a particular parameter in our projects.

 

The body from the results of a search, converted to a String, will need the "customfield_xxxxx" replaced by our parameter name in order to use Jackson objectmapper - since we cannot define the properties in the class they are unknown until they are created.

0 votes
Alexey Matveev
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.
November 2, 2017

Hello, 

You need to use the following rest function 

rest/api/2/issue/createmeta?projectKeys=QA&expand=projects.issuetypes.fields

But it does not tell you which fields are on the screen. It will just tell you what fields are defined for the project in the layout scheme.  

Suggest an answer

Log in or Sign up to answer