[rt-users] Extract Attachment as Mime
Anthony Brodard
anthony at brodard.me
Tue Apr 2 09:19:36 EDT 2013
Hi list,
Hi try to create a scrip which will create a new ticket in an other queue,
with the last comment as body.
Description : On close Create ticket in alerts
Condition : On close
Action : Defined by user
Modèle : null
Step : TransactionCreate
Pre-action code:
return 1;
Custom action :
my $ticket = $self->TicketObj;
my $CF = $ticket->FirstCustomFieldValue('VALIDATION');
my $child_ticket = RT::Ticket->new ( $RT::SystemUser );
my $queue_name = 'Alerts';
return 0 if ($CF ne $queue_name );
my $transactions = $ticket->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'Comment' );
while (my $transaction = $transactions->Next){
$RT::Logger->info("Transaction ". $transaction->id);
my $attachments = $transaction->Attachments;
while (my $attachment = $attachments->Next) {
$RT::Logger->info("Attachment". $attachment->id);
my $content = $attachment->ContentAsMIME;
}
}
my ($child_id, $child_transobj, $errormsg ) = $child_ticket->Create(
Queue => $queue_name ,
Subject => $ticket->Subject,
RefersTo => $ticket->id ,
Owner => $ticket->Owner ,
MIMEObj => $Content,
);
unless ( $child_id ) {
$RT::Logger->debug(">>Error : ". $errormsg);
return 0;
};
return 1;
So, without the while loop and the MIMEObj parameter, the scrip works fine,
and a new ticket is created in the other queue, but with an empty body.
When I add the loop, the scrip fail, and I don't any error log.
Do you have any idea about this problem ?
Best regards,
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130402/bd788da8/attachment.htm>
More information about the rt-users
mailing list