I am trying to implement a custom scrip that send the content of a ticket on status change. So far, I implemented the following in the initialdata file :
@ScripConditions =
{ Name => ‘On Status Change to Sent’,
Description => ‘When a an outgoing report must be sent’,
ApplicableTransTypes => ‘Any’,
ExecModule => ‘StatusChange’,
Argument => ‘old: pending; new: sent’,
}
(at)Scrips =
{ Description => “On status change send outgoing report”,
Queue => ‘Outgoing Reports’,
ScripCondition => ‘On Status Change to Sent’,
ScripAction => ‘Notify Requestors And Ccs’,
Template => ‘CustomTemplate’
}
With this configuration, the system correctly sends an email upon status change (pending->sent) but the content of the mail being sent is always the same :
“This transaction appears to have no content”
My guess is that the “status changed” transaction doesn’t have any content like the “Correspond” or “On create” transaction since nothing has been received during this transition.
I wanted to retrieve the content of the transaction that initially created the ticket (content of the initial mail that created the ticket) . I found a solution using a custom template and it looks like this :
@Templates = (
{
Queue => ‘0’,
Name => ‘CustomTemplate’,
Description => ‘Template for outgoing reports’,
Content =>
'RT-Attach-Message: yes
Content-Type: text
{
my $txs = $Ticket->Transactions;
my $output = "";
while ( my $trans = $txs->Next ) {
next unless $trans->HasContent && $trans->Content;
if($trans->Description =~ m/Ticket created/){
$output = $output . $trans->Content . "\n";
}
}
return $output;
}', },
Basically, the template goes through all the transactions for a given ticket. And for all transactions, it looks if the transaction has some content. If the transaction has some content and that the description of the transaction contains the string ‘Ticket created’, then it has found the content of the initial mail.