Scrip for Default Owners

I’m working on a scrip that I hope will allow new tickets to be
assigned to a default owner per queue. What I have so far is not
causing trouble, but neither is it working – the owner remains
Nobody. Here it is. (On Create, User Defined with template
Transaction.)

Custom action preparation code

return 1;

Custom action cleanup code

my $ticket = $self->TicketObj;

my $ticketsQueue = $ticket->QueueObj->id;

map the numeric IDs of each Queue to a default owner

my %defaultOwners = (
# Queue => user
‘3’ => ‘22’, # Foo => bob
‘4’ => ‘26’, # Bar => carole
‘5’ => ‘28’, # Fud => ted
‘1’ => ‘10’, # General => alice
);

if owner of this new ticket is Nobody

if ($ticket->Owner eq ‘10’) {
# change the owner from Nobody to default for this queue
$ticket->SetOwner($defaultOwners[$ticketsQueue]);
return 1;
}
else {
return undef;
}

What have I done wrong here?

Thanks,
Dave.
Dave Edwards <dle&sympatico,ca>
Freelance and Technical Writer,
With Special Interest in Open Source Software
http://bigStory.homelinux.org

signature.asc (189 Bytes)

I do this with queue-specific scrips, rather than a single global one.
Here’s an example scrip action:

#Custom action preparation code
return 1;

#Custom action cleanup code
if( $self->TicketObj->OwnerObj->Name =~ /Nobody/i ) {
my ($status, $msg) = $self->TicketObj->SetOwner( ‘MarkRoedel’ );
unless( $status ) {
$RT::Logger->warning("Failed to assign owner: " . $msg);
return undef;
}
}
return 1;

Mark Roedel
Web Programmer / Analyst
LeTourneau University-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Dave
Edwards
Sent: Wednesday, March 30, 2005 12:52 PM
To: rt-users@bestpractical.com
Subject: [rt-users] Scrip for Default Owners

I’m working on a scrip that I hope will allow new tickets to be
assigned to a default owner per queue. What I have so far is not
causing trouble, but neither is it working – the owner remains
Nobody. Here it is. (On Create, User Defined with template
Transaction.)

Custom action preparation code

return 1;

Custom action cleanup code

my $ticket = $self->TicketObj;

my $ticketsQueue = $ticket->QueueObj->id;

map the numeric IDs of each Queue to a default owner

my %defaultOwners = (
# Queue => user
‘3’ => ‘22’, # Foo => bob
‘4’ => ‘26’, # Bar => carole
‘5’ => ‘28’, # Fud => ted
‘1’ => ‘10’, # General => alice
);

if owner of this new ticket is Nobody

if ($ticket->Owner eq ‘10’) {
# change the owner from Nobody to default for this queue
$ticket->SetOwner($defaultOwners[$ticketsQueue]);
return 1;
}
else {
return undef;
}

What have I done wrong here?

Thanks,
Dave.
Dave Edwards <dle&sympatico,ca>
Freelance and Technical Writer,
With Special Interest in Open Source Software
http://bigStory.homelinux.org

At Wednesday 3/30/2005 01:52 PM, Dave Edwards wrote:

my %defaultOwners = (
# Queue => user
‘3’ => ‘22’, # Foo => bob
‘4’ => ‘26’, # Bar => carole
‘5’ => ‘28’, # Fud => ted
‘1’ => ‘10’, # General => alice
);

if owner of this new ticket is Nobody

if ($ticket->Owner eq ‘10’) {
# change the owner from Nobody to default for this queue
$ticket->SetOwner($defaultOwners[$ticketsQueue]);

What have I done wrong here?

Curly brackets? $defaultOwners{$ticketsQueue}

The RT log may have shown an error message for this.

Steve

  • Stephen Turner [2005-03-30T15:15-0500]:

Curly brackets? $defaultOwners{$ticketsQueue}

Ah! Thanks. The Perl is rusty.

Dave.
Dave Edwards <dle&sympatico,ca>
Freelance and Technical Writer,
With Special Interest in Open Source Software
http://bigStory.homelinux.org

signature.asc (189 Bytes)