6 # make sure global CFs are not applied to local objects
7 my $ocfs = RT::ObjectCustomFields->new( RT->SystemUser );
8 $ocfs->Limit( FIELD => 'ObjectId', OPERATOR => '!=', VALUE => 0 );
9 my $alias = $ocfs->Join(
10 FIELD1 => 'CustomField',
11 TABLE2 => 'ObjectCustomFields',
12 FIELD2 => 'CustomField',
14 $ocfs->Limit( ALIAS => $alias, FIELD => 'ObjectId', VALUE => 0 );
15 while ( my $ocf = $ocfs->Next ) {
21 my $sth = RT->DatabaseHandle->dbh->prepare(
22 "SELECT cfs.LookupType, ocfs.id"
23 ." FROM ObjectCustomFields ocfs, CustomFields cfs"
24 ." WHERE cfs.id = ocfs.CustomField"
25 ." ORDER BY cfs.LookupType, ocfs.SortOrder, cfs.Name"
29 my ($i, $prev_type) = (0, '');
30 while ( my ($lt, $id) = $sth->fetchrow_array ) {
31 $i = 0 if $prev_type ne $lt;
32 my $ocf = RT::ObjectCustomField->new( RT->SystemUser );
34 my ($status, $msg) = $ocf->SetSortOrder( $i++ );
35 RT->Logger->warning("Couldn't set SortOrder: $msg")