Feature #22297

Group by custom field of type text

Added by syed hussain over 4 years ago. Updated over 2 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:-
Resolution:

Description

We are unable to create a custom field of type text. Group by work for custom fields of type integer etc but "text" format ones cannot be gorup by.

History

#1 Updated by Toshi MARUYAMA over 4 years ago

  • Tracker changed from Defect to Feature
  • Subject changed from Unable to group by custom field of type text to Group by custom field of type text

#2 Updated by Bruno Medeiros almost 3 years ago

This seems to work already, at least in Planio hosted version. Maybe they contribute with a patch if that's the case.

What I see is that we cannot group by a field that is not for "all projects". Does it make sense?

#3 Updated by Felix Schäfer almost 3 years ago

Bruno Medeiros wrote:

This seems to work already, at least in Planio hosted version. Maybe they contribute with a patch if that's the case.

This is something that we would contribute if we were to work on it, but I am not aware this is possible on Planio. Could you double-check that you can group an issue list by a custom field of type "text"?

What I see is that we cannot group by a field that is not for "all projects". Does it make sense?

I am able to group by a custom field that is defined on only one project in that project's issue list. Do you maybe mean that you can only use custom fields defined as "for all projects" to group by on the global issue list?

#4 Updated by Hong Cheu Lim over 2 years ago

This indeed could be achieved by patching, see patch below.
This seem to work for me with minor limitation,i.e. string after n in the example below(255) char will be truncated

diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index fade7c2..ad9041c 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -387,6 +387,10 @@ module Redmine
           value.to_s
         end
       end
+
+      def group_statement(custom_field)
+        "CAST(cf_#{custom_field.id}.value AS char(255))" 
+      end
     end

     class TextFormat < Unbounded

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.4.2-p198 (2017-09-14) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    development
  Database adapter               Mysql2 (mariadb)

Also available in: Atom PDF