[rt-users] Search Ticket Transaction History in Query Builder?

Thomas Sibley trs at bestpractical.com
Wed Jun 13 16:23:05 EDT 2012


On 06/13/2012 04:15 PM, Brian Schrock wrote:
> Custom Condition:
> my $txn = $self->TransactionObj;
> my $type = $txn->Type;
> 
> unless (
>     ($type eq "Status") ||
>     ($type eq 'Set' && $txn->Field eq 'Status') ||
>     ($txn->OldValue eq "resolved") ||
>     ($txn->OldValue eq "stalled") ||
>     ($txn->NewValue eq "open") ||
>     ($txn->Data eq 'Ticket auto-opened on incoming correspondence')
>   ) {

I think your logic is wrong here.  You're OR-ing all those together
instead of a combination of AND and OR with parentheses to group correctly.

>   return 0;
> }
> 
> return 1;
> 
> Custom action cleanup code:
> my $Ticket = $self->TicketObj;
> my $CFName = 'Last Reopened Date';
> my $CF = RT::CustomField->new( $RT::SystemUser );
> $CF->LoadByNameAndQueue( Name => $CFName, Queue => $Ticket->Queue );
> 
> my @date  = localtime(time());
> my $year = $date[5] += 1900 ;
> my $month = $date[4] += 1 ;
> my $day = $date[3] ;
> my $date_stamp = "$year-$month-$day";
> 
> $Ticket->AddCustomFieldValue( Field => $CF, Value => $date_stamp);

Avoid the localtime math and just pass:

  Value => $self->TransactionObj->CreatedObj->AsString




More information about the rt-users mailing list