6 require RT::ObjectScrips;
7 foreach my $stage ('TransactionCreate', 'TransactionBatch') {
8 my $applications = RT::ObjectScrips->new( RT->SystemUser );
9 $applications->Limit( FIELD => 'Stage', VALUE => $stage );
10 my $alias = $applications->Join(
12 TABLE2 => 'Scrips', FIELD2 => 'id'
14 $applications->OrderByCols(
15 { ALIAS => $alias, FIELD => 'Description', ORDER => 'ASC' },
17 my %h; my $top_so = $h{0} = 0;
18 while ( my $record = $applications->Next ) {
19 my $oid = $record->ObjectId || 0;
23 %h = (); $h{0} = $so = ++$top_so;
26 $so = $h{ $oid } = ($h{$oid}||$h{0}) + 1;
28 next if $record->SortOrder == $so;
30 my ($status, $msg) = $record->SetSortOrder($so);
31 RT->Logger->error("Couldn't set sort order: $msg")