Try this patch

On 1/31/07, Audun Ytterdal <[EMAIL PROTECTED]> wrote:
I want to control most of my tickets with mails and I am cc'ing all
tickets in a queue to a group of customers and a shared folder.

Since mail is the main interface i've put some effort into putting some
info in the footer of each mail

<scrip>
Description: 99LinproCorrespond
Condition: On Correspnd
Action: Notify Requestors, Ccs and AdminCcs
Template: Global template: LinproMailTemplateRe
Stage: TransactionCreate
</scrip>

<template>
RT-Attach-Message: yes
Subject: { "Re: [".$RT::rtname." #".$Ticket->id."] ".$Ticket->Subject}

{
 my $content = '';
 my $transactions = $Ticket->Transactions;
 $transactions->Limit( FIELD => 'Type', VALUE => 'Correspond' );

 while (my $transaction = $transactions->Next) {
   my $attachments = $transaction->Attachments;

   while (my $message = $attachments->Next) {
     next unless $message->ContentType =~
              m!^(text/plain|message|text$)!i;

     $content = $message->Content;
   }
 }
 my $output = ($content || $Transaction->Content());
 $output;
}
--
Linproticket: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
[{$Ticket->Status}]
Requestor: {$Ticket->RequestorAddresses} Created: {$Ticket->Created}
Owner: {$Ticket->OwnerObj->EmailAddress || $Ticket->OwnerObj->Name}
Level: {$Ticket->FirstCustomFieldValue('LinproLevel') }
</template>

This works, except the script is firing to soon so the information in
$Ticket-Status and friends is outdated.

After some googling around i found out that this works much better if I
put "on correspondece"  in "TransactionBatch"-stage. All the information
is now up to date and everything works as expected using the
mailinterface to set Owner and Status and such.

BUT, the script now fires twice If I use the webinterface. When I click
on "reply" on a ticket _and_ when I submit  the reply.

If the "on correspondance" is in "TransactionCreate"-Stage: Fire of the
scrip when "update ticket" is clicked. But info is outdated
If the "on correspondance" is in "TransactionBatche"-stage: Fire when
clicking on "reply" and on "update ticket" so I get two mails.

Is there anything I can to the get the benefit of both worlds? Is it a
bug to start a transaction when clicking on reply before you acctually
update it?

--
Audun


--
Best regards, Ruslan.
=== lib/RT/Record.pm
==================================================================
--- lib/RT/Record.pm	(revision 4507)
+++ lib/RT/Record.pm	(local)
@@ -1469,7 +1469,7 @@
         $self->_UpdateTimeTaken( $args{'TimeTaken'} );
     }
     if ( $RT::UseTransactionBatch and $transaction ) {
-	    push @{$self->{_TransactionBatch}}, $trans;
+	    push @{$self->{_TransactionBatch}}, $trans if $args{'CommitScrips'};
     }
     return ( $transaction, $msg, $trans );
 }
=== lib/RT/Ticket_Overlay.pm
==================================================================
--- lib/RT/Ticket_Overlay.pm	(revision 4507)
+++ lib/RT/Ticket_Overlay.pm	(local)
@@ -3433,6 +3433,8 @@
     return if $self->{_Destroyed}++;
 
     my $batch = $self->TransactionBatch or return;
+    return unless @$batch;
+
     require RT::Scrips;
     RT::Scrips->new($RT::SystemUser)->Apply(
 	Stage		=> 'TransactionBatch',
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to