[rt-users] Getting the owner of a ticket fails?

Ruslan Zakirov ruz at bestpractical.com
Tue Oct 21 23:44:43 EDT 2008


On Tue, Oct 21, 2008 at 8:40 PM, kschmitte <kschmitte at voiceobjects.com> wrote:
>
> Hello All,
>
> I'm running a scrip which auto-assigns a ticket to user on the first reply.
> This works very well - if it would not fire the assignement mail twice...
>
> The scrip skeleton is from:
> http://www.nabble.com/automatic-take-td19312788.html#a19313143 (I'm citing
> the nabble RT user list repository for easier access - thread name was
> "automatic take").
>
> What I can see is that the scrip is executed twice - maybe due to what is
> described (and what I don't understand either) in "Correspond Transaction
> Twice on Reply in Batchmode"
> (http://www.nabble.com/Correspond-Transaction-Twice-on-Reply-in-Batchmode-td8730015.html#a8730015).

Do you use transactions batch mode? If no then it's not related.

>
> My issue now is, that when I try to get the owner id, the id did not change
> from 10 (see log messages below "Scrip Auto-Take started.117Owner: 10") to
> #117 - what I would expect here (since the ticket is assigned after the
> first action).
> Is
>    $self->TicketObj->Owner
> not the correct way to get the current owner ID?

It's correct way. Looks like some cache issue.

you can use the following code to check if it's cache issue or not:

my $ticket = RT::Ticket->new( $RT::SystemUser );
$ticket->Load( $self->TicketObj->id );

and then use this object instead of $self->TicketObj

>
> Thanks for any help!
>
> Kai Schmitte
>
>
>
>
>
> -> my code:
> #see http://www.nabble.com/automatic-take-td19312788.html
> my $correspondent = $self->TransactionObj->Creator;
>
> $RT::Logger->info("Scrip Auto-Take started. Current Owner: " .
> $self->TicketObj->Owner);
>
> # don't auto-take for "root"
> return 1 if $correspondent == $RT::SystemUser->id;
>
> # only auto-take if owned by Nobody
> return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;
>
> # don't auto-take if correspondent is requestor
> # see http://wiki.bestpractical.com/index.cgi?OnCreateSetDeptHeadCc
> my $rgobj = $self->TicketObj->Requestors;
> my $rmobj = $rgobj->UserMembersObj;
> my $uobj;
> while ($uobj = $rmobj->Next)
> {
>   if ($uobj->PrincipalObj->Id == $correspondent)
>   {
>        $RT::Logger->info("Not auto-assigning ticket #" .
> $self->TicketObj->id . " to its requestor");
>        return 1;
>   }
> }
>
> $RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to user
> #". $correspondent );
> my ($status, $msg) = $self->TicketObj->SetOwner( $correspondent );
> unless( $status )
> {
>    $RT::Logger->error( "Impossible to assign ticket to $correspondent:
> $msg" );
>    return undef;
> }
> return 1;
>
>
>
> -> the log messages:
> Oct 21 16:48:02 support RT: Scrip Auto-Take started.117Owner: 10 ((eval
> 3112):4)
> Oct 21 16:48:02 support RT: Auto assign ticket #105 to user #117 ((eval
> 3112):30)
> Oct 21 16:48:02 support RT: <rt-3.6.5-19971-1224600482-234.105-2-0@>
> #105/2265 - Scrip 2 Notify Owner on Owner Change
> (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:252)
> Oct 21 16:48:02 support RT: <rt-3.6.5-19971-1224600482-234.105-2-0@> sent
> To: user at company.com
> (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:283)
> Oct 21 17:03:36 support RT: Scrip Auto-Take started.117Owner: 10 ((eval
> 475):4)
> Oct 21 17:03:36 support RT: Auto assign ticket #105 to user #117 ((eval
> 475):30)
> Oct 21 17:03:36 support RT: <rt-3.6.5-23801-1224601416-749.105-2-0@>
> #105/2268 - Scrip 2 Notify Owner on Owner Change
> (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:252)
> Oct 21 17:03:36 support RT: <rt-3.6.5-23801-1224601416-749.105-2-0@> sent
> To: user at company.com
> (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:283)
> --
> View this message in context: http://www.nabble.com/Getting-the-owner-of-a-ticket-fails--tp20094432p20094432.html
> Sent from the Request Tracker - User mailing list archive at Nabble.com.
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>



-- 
Best regards, Ruslan.



More information about the rt-users mailing list