Re: [rt-users] Auto-setting the owner of "child" tickets

2011-08-17 Thread Kevin Falcone
On Tue, Aug 16, 2011 at 11:45:39AM -0400, Chris Hall wrote:
> Hello all,
> 
> Awhile back I set up a custom global scrip to auto-set the owner of a ticket
> to the user like this:
> 
> On Create, action user defined, Global template: Blank, Stage
> TransactionCreate
> 
> Custom action preparation code:
> 
>  return 1;
> 
> Custom action cleanup code:
> # get actor ID
> my $Actor = $self->TransactionObj->Creator;
> 
> # if actor is RT_SystemUser then get out of here
> return 1 if $Actor == $RT::SystemUser->id;
> 
> # get out unless ticket owner is nobody
> return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;
> 
> # ok, try to change owner
> $RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to user
> #".$Actor );
>   my ($status, $msg) = $self->TicketObj->SetOwner( $Actor );
> unless( $status ) {
>   $RT::Logger->error( "Impossible to assign the ticket to $Actor: $msg" );
>   return undef;
> }
> return 1;
> 
> Honestly this is a holdover from another scrip I have that changes the owner
> of a ticket to the user whenever the ticket is commented on.  This is
> working good except that it doesn't seem to work for child tickets.  They
> still inherit the parent's owner as their own.  Anybody know where this is
> going awry?


Are you creating the Create link from the Links box on Ticket Display?
I believe that sets an owner for you, so the owner won't be Nobody.
You'll need to amend your check to say if the owner is the parent's
owner OR nobody, then autoset the owner.


-kevin


pgpxxPeIRWVKz.pgp
Description: PGP signature

RT Training Sessions (http://bestpractical.com/services/training.html)
*  Chicago, IL, USA — September 26 & 27, 2011
*  San Francisco, CA, USA — October 18 & 19, 2011
*  Washington DC, USA — October 31 & November 1, 2011
*  Melbourne VIC, Australia — November 28 & 29, 2011
*  Barcelona, Spain — November 28 & 29, 2011

[rt-users] Auto-setting the owner of "child" tickets

2011-08-16 Thread Chris Hall
Hello all,

Awhile back I set up a custom global scrip to auto-set the owner of a ticket
to the user like this:

On Create, action user defined, Global template: Blank, Stage
TransactionCreate

Custom action preparation code:

 return 1;

Custom action cleanup code:
# get actor ID
my $Actor = $self->TransactionObj->Creator;

# if actor is RT_SystemUser then get out of here
return 1 if $Actor == $RT::SystemUser->id;

# get out unless ticket owner is nobody
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

# ok, try to change owner
$RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to user
#".$Actor );
  my ($status, $msg) = $self->TicketObj->SetOwner( $Actor );
unless( $status ) {
  $RT::Logger->error( "Impossible to assign the ticket to $Actor: $msg" );
  return undef;
}
return 1;

Honestly this is a holdover from another scrip I have that changes the owner
of a ticket to the user whenever the ticket is commented on.  This is
working good except that it doesn't seem to work for child tickets.  They
still inherit the parent's owner as their own.  Anybody know where this is
going awry?

RT Training Sessions (http://bestpractical.com/services/training.html)
*  Chicago, IL, USA — September 26 & 27, 2011
*  San Francisco, CA, USA — October 18 & 19, 2011
*  Washington DC, USA — October 31 & November 1, 2011
*  Melbourne VIC, Australia — November 28 & 29, 2011
*  Barcelona, Spain — November 28 & 29, 2011