Defect #38668
closed
Unable to retrieve custom fields set as "For all projects" via Projects API
Added by Hirokazu Onozato over 1 year ago.
Updated over 1 year ago.
Description
Create a custom field for the Issue and check "For all projects".
When retrieving Issue custom fields in the Projects API, those with "For all projects" checked will not be retrieved.
<projects total_count="2" offset="0" limit="25" type="array">
<project>
<id>1</id>
<name>a</name>
<identifier>a</identifier>
<description/>
<status>1</status>
<is_public>true</is_public>
<inherit_members>false</inherit_members>
<issue_custom_fields type="array">
<custom_field id="2" name="Per Projects"/>
</issue_custom_fields>
<created_on>2023-06-07T09:45:45Z</created_on>
<updated_on>2023-06-07T09:45:45Z</updated_on>
</project>
<project>
<id>2</id>
<name>b</name>
<identifier>b</identifier>
<description/>
<status>1</status>
<is_public>false</is_public>
<inherit_members>false</inherit_members>
<issue_custom_fields type="array"/>
<created_on>2023-06-07T09:45:57Z</created_on>
<updated_on>2023-06-07T09:45:57Z</updated_on>
</project>
</projects>
I thought it should also be possible to retrieve those specified in "For all projects."
I have confirmed that the following modification will result in the intended behavior.
Files
- Related to Feature #33301: Add option to include enabled issue custom fields in projects#show API response added
- Status changed from New to Confirmed
- Target version set to Candidate for next major release
- Target version changed from Candidate for next major release to 5.1.0
The code below is a test for the suggested fix. Setting the target version to 5.1.0.
diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb
index f0c1973cb..c32f7679b 100644
--- a/test/integration/api_test/projects_test.rb
+++ b/test/integration/api_test/projects_test.rb
@@ -86,11 +86,16 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
end
test "GET /projects.xml with include=issue_custom_fields should return custom fields" do
+ IssueCustomField.find(6).update_attribute :is_for_all, true
+ IssueCustomField.find(8).update_attribute :is_for_all, false
get '/projects.xml?include=issue_custom_fields'
assert_response :success
assert_equal 'application/xml', @response.media_type
assert_select 'issue_custom_fields[type=array] custom_field[name="Project 1 cf"]'
+ # Custom field for all projects
+ assert_select 'issue_custom_fields[type=array] custom_field[id="6"]'
+ assert_select 'issue_custom_fields[type=array] custom_field[id="8"]', 0
end
test "GET /projects/:id.xml should return the project" do
- Subject changed from Custom field set in "For all projects" cannot be retrieved by the projects API to Unable to retrieve custom fields set as "For all projects" via Projects API
- Status changed from Confirmed to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you for your contribution.
Also available in: Atom
PDF