[rt-users] Show tickets depending on creator and not owner

Christian Loos cloos at netcologne.de
Tue Jul 5 06:15:16 EDT 2011


Hi Fabian,

you could simplify you script as you don't need the principal stuff 
here. The scrip would then look like this:

my $scrip = 'Script:AutoAddCreatorAsRequestor';

# Get Current Ticket
my $Ticket = $self->TicketObj;
# Get Current Ticket ID
my $Id = $Ticket->id;
# Get E-Mail-Address of creator
my $EmailAddr = $self->TransactionObj->CreatorObj->EmailAddress;
# Type of watch
my $type = 'Requestor';

# Add the creator as a watcher of type $type (requestor)
my ($ret, $msg) = $Ticket->AddWatcher(Type  => $type, Email => $EmailAddr);

# Check if adding was successful
if ($ret) {
   $RT::Logger->info("$scrip: New $type watcher added to ticket #$Id: 
$EmailAddr");
} else {
   $RT::Logger->error("$scrip: Failed to add new $type watcher to ticket 
#$Id: $EmailAddr - $msg");
}

return 1;

But I don't understand why you need this scrip.
How do you create your tickets? Email, WebUI, REST?

If you create your ticket by email RT will automatic load the creator 
(From email address) as the requestor.
If you create you ticket by WebUI, RT put the email address of the 
currently logged in user in the requestor field.

-Chris

Am 04.07.2011 12:02, schrieb Fabian Unfried:
> my $scrip = 'Script:AutoAddCreatorAsRequestor';
>
> # Get Current Ticket
> my $Ticket = $self->TicketObj;
> # Get Current Ticket ID
> my $Id = $Ticket->id;
> # Get E-Mail-Address of creator
> my $EmailAddr = $self->TransactionObj->CreatorObj->EmailAddress;
> # Get user object of creator
> my $User = RT::User->new($RT::SystemUser);
> $User->LoadByEmail($EmailAddr);
> # Type of watch
> my $type = 'Requestor';
> # Principal of user
> my $Principal = $User->PrincipalId;
>
> # Add the creator as a watcher of type $type (requestor)
> my ($ret, $msg) = $Ticket->AddWatcher(Type  => $type, Email =>
> $EmailAddr, PrincipalId => $Principal,);
>
> # Check if adding was successful
> if ($ret) {
>    $RT::Logger->info("$scrip: New $type watcher added to ticket #$Id:
> $EmailAddr (#$Principal)");
> } else {
>    $RT::Logger->error("$scrip: Failed to add new $type watcher to ticket
> #$Id: $EmailAddr (#$Principal) - $msg");
> }
>
> return 1;




More information about the rt-users mailing list