[rt-users] Finding the current user for a reply (scrips)

Howard Jones howie at thingy.com
Fri Oct 9 08:47:53 EDT 2009


On 08/10/2009 17:24, Kevin Falcone wrote:
> Try using $trans->Creator or $trans->CreatorObj
> Scrips run in a system context, but the creator of the transaction
> will be the user who triggered it.
>   
Thanks! That did the trick...

So for the sake of anyone else searching later, here is the final scrip.
There's already another scrip that sets the status back to open on
correspondence.

# get actor ID
my $trans = $self->TransactionObj;
my $Ticket = $trans->TicketObj;
my $Actor = $trans->CreatorObj();

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

# All staff users are in 'RTUsers'.
my $GroupObj = RT::Group->new($Actor);
$GroupObj->LoadUserDefinedGroup( 'RTUsers' );

my $PrincipalObj = RT::Principal->new($Actor);
$PrincipalObj->Load($Actor->id);

if ($GroupObj->HasMemberRecursively($PrincipalObj)) {
      if($Ticket->Status() eq 'open')
   {
     $self->TicketObj->SetStatus('stalled');
  }

}

return 1;



More information about the rt-users mailing list