Trying to sort the values of a CF

Hi All,

I would like to sort the content of a CF of type ‘enter multiple values’.
I had a look at the element displaying this but can’t make this work.
Probably my very weak perl skills are the problem.
The following is from that element:

% $m->callback( CallbackName => ‘BeforeCustomFields’, Object => $Object,
% Grouping => $Grouping, ARGSRef => %ARGS, CustomFields
=> $CustomFields, Table => $Table );
% if ($Table) {

% } % while ( my $CustomField = $CustomFields->Next ) { % my $Values = $Object->CustomFieldValues( $CustomField->Id ); % my $count = $Values->Count; % $m->callback( CallbackName => 'AfterCustomFieldValue', CustomField => $CustomField, % Object => $Object, Grouping => $Grouping, Table => $Table ); % } % if ($Table) {
<% $CustomField->Name %>: % unless ( $count ) { <&|/l&>(no value) % } elsif ( $count == 1 ) { % $print_value->( $CustomField, $Values->First ); % } else {
    % while ( my $Value = $Values->Next ) {
  • % $print_value->( $CustomField, $Value );
  • % }
% }
% } % $m->callback( CallbackName => 'AfterCustomFields', Object => $Object, % Grouping => $Grouping, ARGSRef => \%ARGS, Table => $Table );

The while $value = $values->next’'prints one line at at time the content
of the CF. I would like to sort this content prior to displaying it.

Any help is appreciated,

Joop

I would like to sort the content of a CF of type ‘enter multiple values’.
I had a look at the element displaying this but can’t make this work.
Probably my very weak perl skills are the problem.

How do you want to sort them, can you do a database sort?

% my $Values = $Object->CustomFieldValues( $CustomField->Id );

You can say $Values->OrderBy(FIELD => ‘Content’, ORDER => ‘ASC’);

If you need to do it in perl, you need to rewrite that loop using
ItemsArrayRef and passing through perl’s sort().

Alternately, you could modify the code that stores, since it stores an
OrderBy field which is what RT normally uses to display.

Keep in mind that changing here will not change the editing view while
ensuring SortOrder is correct will work there.

-kevin

I would like to sort the content of a CF of type ‘enter multiple values’.
I had a look at the element displaying this but can’t make this work.
Probably my very weak perl skills are the problem.

How do you want to sort them, can you do a database sort?

% my $Values = $Object->CustomFieldValues( $CustomField->Id );

You can say $Values->OrderBy(FIELD => ‘Content’, ORDER => ‘ASC’);
DBIx::SearchBuilder - Encapsulate SQL queries and rows in simple perl objects - metacpan.org

Thanks Kevin for the hints. I’ll check them out and let the list know.

Joop