Rt3, custom scrip action failing commit (AutoTake)

Ken Bantoft emailed me his code for doing an “AutoTake” but it’s not working
for me and it’s not clear to me how to debug this. Part of the code was
taken from Bruce’s AutoTake scrip from rt2.

I tried changing HasQueueRight to CurrentUserHasQueueRight but that’s also
not defined in RT::Action::UserDefined and I don’t know where/how it should
be.

Aug 1 17:07:08 help2 RT: AutoAssign: No owner - autoassigning ((eval
1765):5)
Aug 1 17:07:08 help2 RT: Scrip 28 Commit failed: RT::User::HasQueueRight
Unimplemented in RT::Action::UserDefined. ((eval 1766) line 4) Stack:
[/usr/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Record.pm:457] [(eval
1766):4] [/opt/rt3/lib/RT/ScripAction_Overlay.pm:192]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:409]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:344]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:169]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:3789]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2314]
[/opt/rt3/lib/RT/Interface/Web.pm:397]
[/opt/rt3/share/html/Ticket/Display.html:99]
[/opt/rt3/share/html/Ticket/Update.html:196]
[/opt/rt3/share/html/autohandler:163]
(/opt/rt3/lib/RT/Action/UserDefined.pm:59)
Aug 1 17:07:08 help2 RT: RT::Scrip=HASH(0x948e4cc): Couldn’t commit User
Defined (/opt/rt3/lib/RT/Scrip_Overlay.pm:345)

Description: Auto Assign
Condition: On Create
Custom Condition:
Action: User Defined
Custom action preparation code:

my $retval = undef;
if ( defined( $self->TicketObj->OwnerObj->id ) ){
# Only change tickets where ID is not already set
if( $self->TicketObj->OwnerObj->Id == $RT::Nobody->Id ){
$RT::Logger->info(“AutoAssign: No owner - autoassigning”);
$retval = 1;
}
}
return ($retval);

Custom action cleanup code:

my $retval = undef;

Are they one of the Privileged few?

if ($self->TransactionObj->CreatorObj->Privileged &&
$self->TransactionObj->CreatorObj->Id != $RT::Nobody->Id ) {

# Can they own a ticket in this queue?
if( $self->TransactionObj->CreatorObj->HasQueueRight(
    QueueObj=>$self->TicketObj->QueueObj, Right => 'OwnTicket' ) ){

    # They can own the ticket.  Make it so.
    $retval =



     $self->TicketObj->SetOwner($self->TransactionObj->CreatorObj->Id );
}

}

return( $retval );

Template: Global Template Blank

matthew zeier | “Nothing in life is to be feared.
InteleNet Communications, Inc. | It is only to be understood.”
(949) 784-7904 | - Marie Curie

I found Peter’s post
(http://lists.fsck.com/pipermail/rt-users/2003-April/013566.html)

and tried his AutoTake code. However, it “fails” to actually keep the
ticket reassigned.

I get

  1. mrz - correspondence added
  2. rt_system - given to mrz
  3. mrz given to nobody

#3 because when replying the Owner was set to Nobody.

How do I get around this?From: “matthew zeier” mrz@intelenet.net
To: rt-users@lists.fsck.com
Sent: Friday, August 01, 2003 5:14 PM
Subject: [rt-users] rt3, custom scrip action failing commit (AutoTake)

Ken Bantoft emailed me his code for doing an “AutoTake” but it’s not
working
for me and it’s not clear to me how to debug this. Part of the code was
taken from Bruce’s AutoTake scrip from rt2.

I tried changing HasQueueRight to CurrentUserHasQueueRight but that’s also
not defined in RT::Action::UserDefined and I don’t know where/how it
should
be.

Aug 1 17:07:08 help2 RT: AutoAssign: No owner - autoassigning ((eval
1765):5)
Aug 1 17:07:08 help2 RT: Scrip 28 Commit failed: RT::User::HasQueueRight
Unimplemented in RT::Action::UserDefined. ((eval 1766) line 4) Stack:
[/usr/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Record.pm:457] [(eval
1766):4] [/opt/rt3/lib/RT/ScripAction_Overlay.pm:192]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:409]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:344]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:169]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:3789]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2314]
[/opt/rt3/lib/RT/Interface/Web.pm:397]
[/opt/rt3/share/html/Ticket/Display.html:99]
[/opt/rt3/share/html/Ticket/Update.html:196]
[/opt/rt3/share/html/autohandler:163]
(/opt/rt3/lib/RT/Action/UserDefined.pm:59)
Aug 1 17:07:08 help2 RT: RT::Scrip=HASH(0x948e4cc): Couldn’t commit User
Defined (/opt/rt3/lib/RT/Scrip_Overlay.pm:345)

Description: Auto Assign
Condition: On Create
Custom Condition:
Action: User Defined
Custom action preparation code:

my $retval = undef;
if ( defined( $self->TicketObj->OwnerObj->id ) ){
# Only change tickets where ID is not already set
if( $self->TicketObj->OwnerObj->Id == $RT::Nobody->Id ){
$RT::Logger->info(“AutoAssign: No owner - autoassigning”);
$retval = 1;
}
}
return ($retval);

Custom action cleanup code:

my $retval = undef;

Are they one of the Privileged few?

if ($self->TransactionObj->CreatorObj->Privileged &&
$self->TransactionObj->CreatorObj->Id != $RT::Nobody->Id ) {

# Can they own a ticket in this queue?
if( $self->TransactionObj->CreatorObj->HasQueueRight(
    QueueObj=>$self->TicketObj->QueueObj, Right => 'OwnTicket' ) ){

    # They can own the ticket.  Make it so.
    $retval =
     $self->TicketObj->SetOwner($self->TransactionObj->CreatorObj->Id );
}

}

return( $retval );

Template: Global Template Blank


matthew zeier | “Nothing in life is to be feared.
InteleNet Communications, Inc. | It is only to be understood.”
(949) 784-7904 | - Marie Curie


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm