[rt-users] capture status change to apply custom filed status

Thomas Sibley trs at bestpractical.com
Thu Sep 20 12:53:12 EDT 2012


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.




More information about the rt-users mailing list