<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2769" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>I doubt this is the correct way of doing it but it
worked for me as my users where pestering me about it.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>What I did was to create a perl script (my perl is very
rusty and very immature so if anyone can make this better be my
guest)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>I couldn't figure out how to put the output of a select
query into a perl array so I just created a bash script that called the perl
script (nasty!)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>-----------</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>#!/bin/bash</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=908102021-23102005>echo "select Name from CustomFieldValues where
CustomField = 5 order by Name into outfile '/tmp/mysqlselect' LINES TERMINATED
BY '\n';"|mysql -Drt3<BR>/home/test/perltest.pl<BR>rm -f
/tmp/mysqlselect<BR>-----------</SPAN></FONT></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2>Obviously here you need to find out the value of your CustomField
beforehand</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>and
the perl is (I went to perl as I had issues with trying to get the bash array
going properly)</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2>-----------</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2>#!/usr/bin/perl</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>use
DBI();</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>
# Connect to the database.<BR>my $dbh =
DBI->connect("DBI:mysql:database=rt3;host=localhost",<BR>
"root",
"blah",<BR>
{'RaiseError' => 1});</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>my
$data_file;<BR>$data_file="/tmp/mysqlselect";<BR>open(DAT, $data_file) ||
die("Could not open
file!");<BR>@names=<DAT>;<BR>close(DAT);</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>my
$count=0;<BR>foreach $names (@names)
{<BR>
chop($names);<BR> print "UPDATE
CustomFieldValues SET SortOrder = $count WHERE Name = '$names'\;\n
";<BR> $dbh->do("UPDATE
CustomFieldValues SET SortOrder = $count WHERE Name =
'$names'");<BR>
$count++;<BR>}<BR>----------------------------</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>I just
added this to a cron script to run every night at 12 or something so any updates
will only be visible to the user after that unless you manually run it each
time.</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>And
this has sorted the customfields alphabetically and got my users off my back for
now.</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff size=2>There
must be a better way than this but I didn't have the time to look into it too
much (likewise for my select going directly to the array!)</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2>Cheers</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2>Brent</FONT></SPAN></DIV>
<DIV><SPAN class=908102021-23102005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] <B>On Behalf Of
</B>Brent<BR><B>Sent:</B> 20 October 2005 18:27<BR><B>To:</B>
rt-users@lists.bestpractical.com<BR><B>Subject:</B> [rt-users] Custom fields
sort order<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>Hi</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial size=2>Is there a way to
change the order of custom fields so they can be sorted
alphabetically?</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial size=2>For eg when adding
items to a custom field I would like it to automatically sort the items
alphabetically instead of numerically.</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial size=2>So items inserted
in this order</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ba</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>aa</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ca</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ab</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial size=2>get sorted to
</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>aa</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ab</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ba</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2>ca</FONT></SPAN></DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=774344014-19102005><FONT face=Arial size=2>etc
etc?</FONT></SPAN></DIV></BLOCKQUOTE></BODY></HTML>