Getting the owner of a ticket fails?

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).

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?

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 Request Tracker Wiki

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
(/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
(/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

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 Request Tracker Wiki

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@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@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.


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@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.

Hello Ruslan,

Thanks for the advice!

Ruslan Zakirov-2 wrote:

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

I was not successful - but I only exchanged $self->TicketObj->Owner in the
check for the user ID with $ticket->Owner. I will next try it with
exchanging every occurrence.

Ruslan Zakirov-2 wrote:

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.

I think Trasaction Batch Mode is for newer Version of RT? I’m using 3.6.5
and can’t see anything like that …

Thanks - and best regards,

Kai
View this message in context: http://www.nabble.com/Getting-the-owner-of-a-ticket-fails--tp20094432p20150417.html

Ok. That didn’t make it either.

I get the same logging:

Oct 27 14:45:23 support RT: Scrip Auto-Take started. Owner: 10 to be
assigned to 22 ((eval 3065):11)

Oct 27 14:45:23 support RT: Auto assign ticket #124 to user #22 ((eval
3065):33)

Oct 27 14:45:24 support RT: #124/2807 - Scrip 2 Notify Owner on Owner
Change (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:252)

Oct 27 14:45:24 support RT: sent To: me@.com
(/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:283)

Oct 27 14:45:52 support RT: Scrip Auto-Take started. Owner: 10 to be
assigned to 22 ((eval 497):11)

Oct 27 14:45:52 support RT: Auto assign ticket #124 to user #22 ((eval
497):33)

Oct 27 14:45:53 support RT: #124/2810 - Scrip 2 Notify Owner on Owner
Change (/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:252)

Oct 27 14:45:53 support RT: sent To: me@.com
(/usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm:283)

When I now look with 2 users into RT, I can see the following behaviour:

  1. My user1 opens a ticket and chooses “Reply”

    user2 sees the ticket owned by nobody

  2. user1 gets a mail “Ticket assigned to you”

    even after a refresh user2 sees the ticket owned by nobody

  3. user1 sends the response

    after a refresh user2 sees the ticket owned by user1

The message for the owner change tells me that the owner change was
successful.

Is there a way to find out why this happens?
Or may it be connected with the owner dropdown in a response? When I open
the response, the owner is shown as nobody. As the script then sets the
owner to my user, could it be that the owner is set to nobody again on
submit of my response - and then to me again?

When I set the owner to myself in the dropdown in the response page, I get
three notifications. That’s also weird, as I would expect that in this case
the owner is definitly set - and the third notification should not be sent.

Or does RT load all objects in a cache on reply (and takes every information
from this cache as long as the action is not completed)? In this case I
should be able to set a temporary variable to track if there has been a
second call to the scrip?

Thanks for any help!

Kai

View this message in context: http://www.nabble.com/Getting-the-owner-of-a-ticket-fails--tp20094432p20188856.html