On 09/19/2012 11:31 PM, Asanka Gunasekera wrote:
>     Description: On Open change Correspond Status
>     Condirion: On Create
>     Action: User Defined
>     Template: Global template: Blank
>     stage: TransactionCreate
> 
>     Custom condition:
> 
>     my $txn = $self->TransactionObj;
>     my $type = $txn->Type;
>     return 0 unless $type eq "Status"
>         || ( $type eq 'Set' && $txn->Field eq 'Status');
> 
>     return 0 unless $txn->OldValue eq "new";
>     return 0 unless $txn->NewValue eq "open";
>     return 1;

Custom condition makes no sense since you're using the built-in On
Create condition.  It's not getting run, and you should remove it.

>     Custom action preparation code:
>    
>     my ($success, $msg) = $self->TicketObj->AddCustomFieldValue(Field =>
> 'Correspond Status', Value => 'Work in Progress');
>     if (!$success) {
>     $RT::Logger->error($msg);
>     return 0;
>     }
>     return 1;

All actions should be in the "Custom action cleanup code".  Prepare is
used to check if the action can run, and in your case it should simply
return 1.  Putting record updates in Prepare means you might end up with
duplicate transactions.


--------
Final RT training for 2012 in Atlanta, GA - October 23 & 24
  http://bestpractical.com/training

We're hiring! http://bestpractical.com/jobs

Reply via email to