[rt-users] displaying history in resloved auto-response

Bruce Campbell bruce_campbell at ripe.net
Wed Nov 13 12:38:37 EST 2002


On Wed, 13 Nov 2002, Christen R. Pacheco wrote:

> Is anyone doing this?? The boss has asked me and I am trying but don't
> know if it is possible to call the history to be displayed inside the
> resolved scrips template?

You want something like the following in your template, in addition to
the normal guff:

-- 

Hi.  My name is 'An Example Template'.  You probably know me from such
famous movies such as.. such as.. well, they're not important right now.
What is important is the bits between the '{' and '}' symbols, which is
executed as perl with a few predefined variables.

{ my $have_last=0;
  my $retval = undef;
  my $diag = undef;
  my $newtrans=$Ticket->Transactions;

  # Use DESC if you want it in reverse order
  # Use ASC if you want it in arrived order
  $newtrans->OrderBy( FIELD => 'id', ORDER => 'DESC' );

  # Loop until we run out.
  while( (my $thistrans = $newtrans->Next) && ($have_last == 0) ){
    $diag .= "TransId: " . $thistrans->id . " Type: " . $thistrans->Type();
    # extra line as we word-wrapped
    $diag .= "\n";

    # Only dump out correspondence.
    next unless( $thistrans->Type() eq 'Correspond' );

    # Have this if you only want the last one, comment out if you
    # want all of them.
    $have_last++;

    # If you want a seperator between messages
    $retval .= "-------------------------------------------------------";

    # Add the content.
    $retval .=$thistrans->Content;
  }

  # If you want to print the diag.
  # $retval = $retval . "\nDIAG: \n" . $diag;

  return( $retval );
}

Hi, you're still in the Template.

-- 

This code does work (as given) with Odhiambo, and should work with the
changes suggested if you wish to show all the history.  For further
detail, see the /Ticket/Elements/ShowHistory and
/Ticket/Elements/ShowTransaction .

Regards,

-- 
                             Bruce Campbell                            RIPE
                   Systems/Network Engineer                             NCC
                 www.ripe.net - PGP562C8B1B             Operations/Security






More information about the rt-users mailing list