I’m off and running.
Thanks again.
Emmanuel Lacour wrote:> On Tue, Aug 19, 2008 at 11:38:35AM -0400, Andrew Libby wrote:
Greetings,
I’m using RT, and use a variety of custom fields.
I’d like to have the queue, and some default values for
custom fields set on tickets “automagically”. The ideal
solution for me would be to set the queue based on a lookup
in some data that relates queues to email domains, or
whole email addresses. Then custom fields like customer,
billing rate, owner, etc could be set at the same time.
I seem to be spending more and more time maintaining these
fields. I’d love a solution to this issue. I’ve
experimented with scrips, but never really got it down.
I imagine others have dealt with the likes of this before?
Most of our tickets are created via the mail gateway, so
either a replacement for, or enhancement to that would be
ideal.
You just have to write an RT scrip that do that.
For example, here, all emails comes to a queue named “support”, we have a
scrip like this which lookup the requestor in our customer DB and move the
ticket to the right queue (one queue per customer here, but this can be also a
customfield). Hope this can help you writting the correct scrips for your
setup.
Condition: On Create
Action: User defined
Template: empty
Stage: TransactionCreate
Action:
Creator
my $Actor = $self->TransactionObj->Creator;
Not for RT_SystemUser
return 1 if $Actor == $RT::SystemUser->id;
Creator Email
my $CurrentUser = RT::CurrentUser->new();
$CurrentUser->Load($Actor);
my $email = $CurrentUser->EmailAddress;
$RT::Logger->info(“AutoQueue: Creator: $email”);
Queue
my $Queue = $self->TicketObj->QueueObj;
Only for queue support
return 1 if ($Queue->Name ne ‘support’);
Get the customer
my $newqueue;
use Net::LDAP;
use Net::LDAP::LDIF;
my $binddn = “”;
my $bindpw = “”;
my $base = “ou=customers,o=foo-bar”;
my $host = “ldaps://ldap.foo-bar.fr/”;
$RT::Logger->info(“AutoQueue: Ldap connect”);
my $ldap = Net::LDAP->new($host);
$RT::Logger->info(“AutoQueue: Ldap bind”);
$ldap->bind(“$binddn”, password => “$bindpw”, version => 3) if ($binddn && $bindpw);
$RT::Logger->info(“AutoQueue: Ldap search”);
my $mesg = $ldap->search(base => $base , filter => “(&(objectclass=eecustomerpeople)(mail=$email))”, attrs => [ ‘dn’ ]);
Check we get only one customer
if ($mesg->count == 1) {
my $entry = $mesg->entry(0);
$newqueue = $entry->dn();
$newqueue =~ s/^.*,uid=([^,]+),ou=customers,o=foo-bar/$1/;
$RT::Logger->info(“AutoQueue: Newqueue: $newqueue”);
$ldap->unbind;
} else {
$RT::Logger->info(“AutoQueue: Ldap disconnect”);
$ldap->unbind;
return 1;
}
Change queue
if ($newqueue) {
$RT::Logger->info(“AutoQueue: Queue change”);
my ($status, $msg) = $self->TicketObj->SetQueue($newqueue);
unless ($status) {
$RT::Logger->warning(“AutoQueue: unable to set new queue”);
return undef;
}
}
return 1;