Interesting Reset ticket On Queue Change

Hi all,

I have a UI scrip that reset ticket’s status to ‘new’ and owner to 'nobody’
based on condition ‘On Queue Change’.
let’s say, userA has the both rights to own tickets in the original queue
and new queue,
userA go to an “opened&taken” ticket modify page, and ONLY change the ticket
to a new queue,
at the same time, the status keep “open (unchanged)” and the owner shown is
still “userA”,
after userA ‘save changes’, the scrip run but the owner keep back!!
Does anyone know why? or I miss something important?

here are history:

Fri Jul 20 08:25:48 2007 RT_System - Status changed from ‘open’ to 'new’
Fri Jul 20 08:25:48 2007 RT_System - Owner forcibly changed from userA to
Nobody
Fri Jul 20 08:25:48 2007 userA - Given to userA

here are scrip codes, you may have a try

my ($status)= $self->TicketObj->SetStatus(“new”);
unless( $status ) {
$RT::Logger->warning( “Impossible to reset the ticket to New” );
return undef;
}

my $Actor = $self->TransactionObj->Creator;
return 1 if $Actor == $RT::SystemUser->id;
return 1 if $self->TicketObj->Owner == RT::Nobody->id;

my ($status)= $self->TicketObj->SetOwner(RT::Nobody->id ,“Force”);
unless( $status ) {
$RT::Logger->warning( “Impossible to reset the ticket to Nobody” );
return undef;
}
return 1;

Best Regards,
Steven Liu
HKG RI-CI

Tel: +852 2823 4396
Email: yanfat.liu@kuehne-nagel.com

Hi,

i think the reason for this is a little bug/missing item.
At the ticket basic page, in the owner drop down list is an “(Unchanged)” option missing.
So if you change anything on the basic page (for example the queue) rt thinks you have changed the owner.

If have the same problem with one of my script.
It changes the owner to Nobody on resolve.
If you resolve from the reply/comment page the owner is changed to Nobody.
If you change the status to resolved on the ticket basic page the owner ist changed to Nobody and right changed back to the old owner.

Best Regards,
Christian Loos

Hi Torsten, Joby Walker, Christian Loos,

Thanks for your reply.

For the scrips by provided by Joby,
i think your main concern is that the user is owning a ticket, and there was
bug if he DONT have right to own the new queue, it would wrongly assigned to
that user! The scrip work perfectly before that bug is fixed…seems, but
i’m not sure about RT 3.4.X…I cant remeber exactly from my finding.
So, i did some testing…as said by Torsten, unless you are the owner or
ticket is unwoned, the owner cant be changed.
Also, i found that after the bug is fixed, except the ‘super user’ who can
own all tickets, can do this.
but after the bug fixed, say a user has right to own tickets ONLY in both
queue1 and queue2, he can change tickets ONLY within these 2 queues, and
applying UI scrip for reseting, problem occured as it roll back to that
user!!

And for Loos,
seems we have same condition. and i would like to ask, there is even no
‘Unchanged’ option for drop down list of ‘Status’. so, why it can be reset
by scrip back to ‘new’, but problem exist on ‘Owner’?
Please advise.

Best Regards,

Steven Liu
HKG RI-CI

Tel: +852 2823 4396
Email: yanfat.liu@kuehne-nagel.com-----Original Message-----

Date: Fri, 20 Jul 2007 09:33:51 -0700
From: Joby Walker joby@u.washington.edu
Subject: Re: AW: [Rt-devel] Interesting Reset ticket On Queue Change
Cc: rt-devel@lists.bestpractical.com
Message-ID: 46A0E3EF.4020006@u.washington.edu
Content-Type: text/plain; charset=UTF-8

We use two scrips:

  1. change the status to new on queue change:

Condition: “On Queue Change”
Action: “User Defined”
Template: “Global Template: Blank”

Custom Action prep code:
return 1;
Custom Action cleanup code:
$self->TicketObj()->setStatus(‘new’);
return 1;

  1. Dropping the owner if they do not have permission to own the ticket
    in the new queue:

Condition: “On Queue Change”
Action: “User Defined”
Template: “Global Template: Blank”

Custom Action prep code:
my $t = $self->TicketObj;

if ($t->HasRight( Right => ‘OwnTicket’, Principal => $t->OwnerObj)) {
return 0;
} else {
return 1;
}
Custom Action cleanup code:
my ($status, $msg) = $self->TicketObj->SetOwner(‘Nobody’, ‘Force’);
unless ($status) {
$RT::Logger->error($msg);
}
return $status;

Joby Walker
C&C SSG, University of Washington