Guest User

Request Tracker template for history after queue change

a guest
Feb 13th, 2019
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Subject: {if ($Transaction->Subject) { $Transaction->Subject }
  2.            elsif ($Ticket->Subject) { $Ticket->Subject }
  3.            else { "(No subject given)" }}
  4. RT-Attach-Message: yes
  5.  
  6. {$Transaction->CreatedAsString}: Request {$Ticket->id} changed it's QUEUE. Actual ticket properties and ticket history follows.
  7.  
  8. ** Transaction: {$Transaction->Description} **
  9. **   New queue: {$Ticket->QueueObj->Name} **
  10.  
  11.     Subject: {if ($Transaction->Subject) { $Transaction->Subject }
  12.           elsif ($Ticket->Subject) { $Ticket->Subject }
  13.           else { "(No subject given)" }}
  14.       Owner: {$Ticket->OwnerObj->Name}
  15.  Requestors: {$Ticket->RequestorAddresses}
  16.         Ccs: {$Ticket->CcAddresses}
  17.    AdminCcs: {$Ticket->AdminCcAddresses}
  18.      Status: {$Ticket->Status}
  19.  Ticket URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
  20.  
  21. {if ($Transaction->Content() ne "This transaction appears to have no content")  {$Transaction->Content()}}
  22.  
  23. ----------------------------------------------------------------
  24.  User's original request:
  25. ----------------------------------------------------------------
  26.  
  27.    Time: {$Ticket->Transactions->First->CreatedObj->AsString;}
  28. Subject: {$Ticket->Transactions->First->Subject;}
  29.    From: {$Ticket->Transactions->First->Attachments->First->GetHeader('From')}
  30.      To: {$Ticket->Transactions->First->Attachments->First->GetHeader('To')}
  31.      Cc: {$Ticket->Transactions->First->Attachments->First->GetHeader('Cc')}
  32.  
  33. {$Ticket->Transactions->First->Content()}
  34.  
  35. ---------------------------------------------------------------
  36.   Complete ticket history (oldest messages first):
  37. ----------------------------------------------------------------
  38.  
  39. {
  40.  my $resolved_message = '';
  41.  my $last_content = '';
  42.  
  43.  my $transactions = $Ticket->Transactions;
  44.  $transactions->Limit( FIELD => 'Type', VALUE => 'Correspond',
  45. ENTRYAGGREGATOR => 'OR', OPERATOR => '=', );
  46.  $transactions->Limit( FIELD => 'Type', VALUE => 'Comment',
  47. ENTRYAGGREGATOR => 'OR', OPERATOR => '=', );
  48.  
  49.  while (my $transaction = $transactions->Next) {
  50.    my $attachments = $transaction->Attachments;
  51.  
  52.    while (my $message = $attachments->Next) {
  53.      next unless $message->ContentType =~
  54.               m!^(text/plain|message|text$)!i;
  55.  
  56.      my $content = $message->Content;
  57.      next unless $content;
  58.  
  59.      next if $last_content eq $content;
  60.      $last_content = $content;
  61.  
  62.      my $subject = ($message->Subject || $Ticket->Subject);
  63.  
  64.      my $wrapper = Text::Wrapper->new(columns=>70);
  65.      $content = $wrapper->wrap($content);
  66.  
  67.      $resolved_message .= "Subject: ";
  68.      $resolved_message .= $subject;
  69.      $resolved_message .= "\n";
  70.      $resolved_message .= "From: ";
  71.      $resolved_message .= $message->CreatorObj->RealName ||
  72. $message->CreatorObj->EmailAddress;
  73.      $resolved_message .= "\n";
  74.      $resolved_message .= "Time: ";
  75.      $resolved_message .= $message->CreatedObj->AsString;
  76.      $resolved_message .= "\n";
  77.      $resolved_message .= "\n";
  78.      $resolved_message .= "$content\n";
  79.      $resolved_message .=
  80. "------------------------------------------------\n";
  81.    }
  82.  }
  83.  $resolved_message;
  84. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×