Hi friends,
We have a customfield.{SortOrder} where users input numbers {1,2,3, 3.1, 3.3, 5,11, etc..}.
When i try to do OrderBy in the Result.html, they are sorted as string, causing 11 to be before 2.
I’ve tried using $OrderBy = ‘CAST(CustomField.{SortOrder} AS SIGNED)’; but its not sorting properly.
5 would come before 1
Any idea?
Thanks!
elacour
November 10, 2025, 8:56am
2
Since RT 5.0 (I think) there is a support for sorting numerical customfields. But it’s not yet an easy configuration, you have to override RT::CustomField to mark the named CustomField as Numeric by returning true to the IsNumeric method: RT::CustomField - RT 6.0.2 Documentation - Best Practical
1 Like
elacour
November 10, 2025, 9:02am
3
To help, you need to create a local/lib/RT/CustomField_Local.pm with content like this (for a CF named “MyCustomField)”:
package RT::CustomField;
use strict;
no warnings qw(redefine);
sub IsNumeric {
my $self = shift;
return 1 if ( $self->Name eq 'MyCustomField' );
return 0;
}
1;
make sure you restart your web service after.
elacour
November 10, 2025, 9:10am
4
elacour:
Since RT 5.0 (I think)
5.0.6: RT 5.0.6 Release Notes - RT: Request Tracker - Best Practical
* Internal support to search/sort cf values numerically
* Support to calculate numeric custom fields in search charts
LIfe Saver! It works now! thanks!
1 Like