[rt-users] Forcing Status Changes
Gene LeDuc
gleduc at mail.sdsu.edu
Tue Jul 17 11:35:55 EDT 2007
Hi Mario,
First of all, keep in mind that I've never used custom status codes, so if
they are set differently than the standard status codes then my code
probably won't do what you want.
The first thing you should do is set your logging to debug (in the RT
config file). Then stick logging statements wherever you think you might
want to know what is happening and watch what gets reported in your rt.log.
I'd start with these:
Put a command like this in the custom condition code right before the
"return $val;" statement:
$RT::Logger->debug("Custom condition is " . ($val ? "True" : "False"));
And then this in the commit code right before your if statement:
$RT::Logger->debug("Action code: Transaction OldValue is ($Old), NewValue
is ($New)");
And then this in the block where you change the status, right after the if
statement:
$RT::Logger->debug("Action code, changing status to ($Old)");
Take a look at the rt.log file and see what is going on.
Good luck!
Gene
At 06:55 AM 7/17/2007, Mario Gomide wrote:
>Hi Gene, hi list,
>
>I've tried out what you said, but nothing different is happening. I can
>understand the logic and what the scrip does, so I tried some changes on
>the custom commit action, but with no results.
>How could I debug this scrip? I could start trying to do some other
>changes and writing new scrips, but for any change, I don't actually see
>any results at all. Maybe i'm forgetting something, like "activating" the
>scrip or something like that.
>
>Any ideas or anywhere to look up?
>Thanks again!
>
>Mario Gomide
>
>
>Gene LeDuc escreveu:
>>Hi Mario,
>>
>>What you want to do can be done in RT with an OnStatusChange scrip that
>>checks $self->TransactionObj->OldValue and
>>$self->TransactionObj->NewValue. If the values don't meet your criteria,
>>change the status back to the OldValue. I've never used custom status
>>values, so if they require unusual handling then this might not work. If
>>they work like standard status values, something like this should do the trick:
>>
>>Condition: User Defined
>>Action: User Defined
>>Template: Global blank
>>
>>Custom condition:
>>{ ### true if transaction is a status change
>> my $Transaction = $self->TransactionObj;
>> my $val = $Transaction->Type eq "Status";
>> return $val;
>>}
>>
>>Custom prep action:
>>return 1;
>>
>>Custom commit action:
>>### Check to make sure new status value makes sense
>>my $Transaction = $self->TransactionObj;
>>my $Ticket = $self->TicketObj;
>>my $Old = $Transaction->OldValue;
>>my $New = $Transaction->NewValue;
>>if ($Old eq "X" && ! ($New eq "Y" || $New eq "Z")) {
>> $Ticket->_Set(Field=>"Status", Value=>$Old, RecordTransaction=>0);
>>}
>>return 1;
>>
>>I just typed this in without confirming that it works as-is, so there
>>might be something off in the syntax, but here's what it's doing:
>>1. Fire the scrip if there's been a status change
>>2. See if the old value was "X" and the new value is not "Y" or "Z".
>>If so...
>>3. Set the status back to the old value without creating a transaction
>>(so scrips don't fire again)
>>
>>Since you have a specific list of allowed changes ("Y" and "Z") you don't
>>have to concern yourself with "A".
>>
>>Regards,
>>Gene
>>
>>At 09:56 AM 7/6/2007, Mario Gomide wrote:
>>>Hello list,
>>>
>>>I am trying to set RT to work allowing or denying certain custom statuses.
>>>For example, I have the "X" custom status and whenever a ticket has this
>>>status, the next status can only be "Y" or "Z", but it cannot be "A".
>>>
>>>I read the foruns and I'm still not sure if it can be done by crating
>>>scrips or by modifying Ticket_Overlay.pm (or any other file).
>>>
>>>Actually, I've started creating scripconditions that check the current
>>>status, but now I have to create the scripactions that compare the next
>>>status with the active status, and then it will take some action: if it
>>>isn't a possible status change, then go back and warn. If it is a
>>>possible status change, go ahead and change.
>>>
>>>Has anyone tried to do this? Is there any other easier way? Is there
>>>something done, like forcing the status changes?
>>>
>>>Thanks a lot!
>>>Any suggestions are welcome!
>>>
>>>Mario Gomide
>>>_______________________________________________
>>>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
>>
>_______________________________________________
>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
--
Gene LeDuc, GSEC
Security Analyst
San Diego State University
More information about the rt-users
mailing list