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

Fabian Unfried funfried at zebra.com
Wed Jul 6 03:55:49 EDT 2011


Hi Chris,

first of all thanks for improving my script.

I create my tickets vie the WebUI, but RT doesn't add the logged in user as a requestor in my RT instance. Do I have to configure this somehow, or should this be the default? As I already mentioned some mails before (at least I think so): I'm using RT 4.0.1. Any ideas?

Regards,
Fabian

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;




--
Fabian Unfried
Senior Software Engineer
Zebra Enterprise Solutions

Rossfelder Str. 65/5, 74564 Crailsheim, Germany
T+49 7951 96360 F+49 7951 963611
funfried at zebra.com<mailto:funfried at zebra.com>
www.zebra.com/zes<http://www.zebra.com/zes>
WhereNet * proveo * Multispectral Solutions

Managing Directors Zebra Enterprise Solutions GmbH:
Phil Gerskovich, Gilles Pelzer, Michael Smiley
Registered Office: Ulm, HRB 721672
VAT Number: DE225496806


________________________________
- CONFIDENTIAL-

This email and any files transmitted with it are confidential, and may also be legally privileged. If you are not the intended recipient, you may not review, use, copy, or distribute this message. If you receive this email in error, please notify the sender immediately by reply email and then delete this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110706/b93a3712/attachment.htm>


More information about the rt-users mailing list