Custom fields sort order

Hi
Is there a way to change the order of custom fields so they can be sorted
alphabetically?
For eg when adding items to a custom field I would like it to automatically
sort the items alphabetically instead of numerically.

So items inserted in this order

ba
aa
ca
ab

get sorted to

aa
ab
ba
ca

etc etc?

I doubt this is the correct way of doing it but it worked for me as my users
where pestering me about it.
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)
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!)

#!/bin/bash

echo “select Name from CustomFieldValues where CustomField = 5 order by Name
into outfile ‘/tmp/mysqlselect’ LINES TERMINATED BY ‘\n’;”|mysql -Drt3
/home/test/perltest.pl
rm -f /tmp/mysqlselect
Obviously here you need to find out the value of your CustomField beforehand
and the perl is (I went to perl as I had issues with trying to get the bash
array going properly)
#!/usr/bin/perl

use DBI();

Connect to the database.

my $dbh = DBI->connect(“DBI:mysql:database=rt3;host=localhost”,
“root”, “blah”,
{‘RaiseError’ => 1});

my $data_file;
$data_file=“/tmp/mysqlselect”;
open(DAT, $data_file) || die(“Could not open file!”);
@names=;
close(DAT);

my $count=0;
foreach $names (@names) {
chop($names);
print "UPDATE CustomFieldValues SET SortOrder = $count WHERE Name =
‘$names’;\n ";
$dbh->do(“UPDATE CustomFieldValues SET SortOrder = $count WHERE Name
= ‘$names’”);
$count++;
}

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.
And this has sorted the customfields alphabetically and got my users off my
back for now.
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!)

Cheers
BrentFrom: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Brent
Sent: 20 October 2005 18:27
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Custom fields sort order

Hi
Is there a way to change the order of custom fields so they can be sorted
alphabetically?
For eg when adding items to a custom field I would like it to automatically
sort the items alphabetically instead of numerically.

So items inserted in this order

ba
aa
ca
ab

get sorted to

aa
ab
ba
ca

etc etc?

You want to change the order of the custom fields themselves,
or the values stored in each custom field?On Thu, Oct 20, 2005 at 06:26:31PM +0100, Brent wrote:

Hi
Is there a way to change the order of custom fields so they can be sorted
alphabetically?
For eg when adding items to a custom field I would like it to automatically
sort the items alphabetically instead of numerically.

So items inserted in this order

ba
aa
ca
ab

get sorted to

aa
ab
ba
ca

etc etc?


The rt-users Archives

Be sure to check out the RT Wiki at http://wiki.bestpractical.com

Buy your copy of our new book, RT Essentials, today!

Download a free sample chapter from http://rtbook.bestpractical.com

You want to change the order of the custom fields themselves,
or the values stored in each custom field?

I believe the original querent wants to sort the responses in the pick
list; I, on the other hand, want to rearrange the order of the fields
on the screen.

So feel free to answer both questions. :slight_smile:

Cheers,
– jra
Jay R. Ashworth jra@baylink.com
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274

"NPR has a lot in common with Nascar... we both turn to the left."
	- Peter Sagal, on Wait Wait, Don't Tell Me!

You want to change the order of the custom fields themselves,
or the values stored in each custom field?

I believe the original querent wants to sort the responses in the pick
list; I, on the other hand, want to rearrange the order of the fields
on the screen.

So feel free to answer both questions. :slight_smile:

Doesn’t the page where yo assign the custom fields to the queues
allow you to sort them?

You want to change the order of the custom fields themselves,
or the values stored in each custom field?

I believe the original querent wants to sort the responses in the pick
list; I, on the other hand, want to rearrange the order of the fields
on the screen.

So feel free to answer both questions. :slight_smile:

Doesn’t the page where yo assign the custom fields to the queues
allow you to sort them?

On reflection, I guess it does. Since that was his question, not mine,
I wasn’t thinking about that.

Is there anyway to resort the order in which they appear on the page?

(and my companion question: what’s the easiest way to get the
ticket-level fields to appear on the tranx-level page?)

Cheers,
– jra
Jay R. Ashworth jra@baylink.com
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274

"NPR has a lot in common with Nascar... we both turn to the left."
	- Peter Sagal, on Wait Wait, Don't Tell Me!

You want to change the order of the custom fields themselves,
or the values stored in each custom field?

I believe the original querent wants to sort the responses in the pick
list; I, on the other hand, want to rearrange the order of the fields
on the screen.

So feel free to answer both questions. :slight_smile:

Doesn’t the page where yo assign the custom fields to the queues
allow you to sort them?

On reflection, I guess it does. Since that was his question, not mine,
I wasn’t thinking about that.

Is there anyway to resort the order in which they appear on the page?

(and my companion question: what’s the easiest way to get the
ticket-level fields to appear on the tranx-level page?)

That is how you get them to the order you want.

http://yourhost/Admin/Queues/CustomFields.html?SubType=RT::Ticket&id=1

I believe the original querent wants to sort the responses in the pick
list; I, on the other hand, want to rearrange the order of the fields
on the screen.

So feel free to answer both questions. :slight_smile:

Doesn’t the page where yo assign the custom fields to the queues
allow you to sort them?

On reflection, I guess it does. Since that was his question, not mine,
I wasn’t thinking about that.

Is there anyway to resort the order in which they appear on the page?

(and my companion question: what’s the easiest way to get the
ticket-level fields to appear on the tranx-level page?)

That is how you get them to the order you want.

http://yourhost/Admin/Queues/CustomFields.html?SubType=RT::Ticket&id=1

I apologize; clearly that’s something I should have found myself.

Thanks, Todd.

Cheers,
– jra
Jay R. Ashworth jra@baylink.com
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274

"NPR has a lot in common with Nascar... we both turn to the left."
	- Peter Sagal, on Wait Wait, Don't Tell Me!