On Tue, Jul 5, 2011 at 5:51 PM, Kenneth Crocker <[email protected]> wrote: > Mauricio, > > Who are you sending the email to? > The new ticket owner.
> Kenn > LBNL > > On Tue, Jul 5, 2011 at 12:35 PM, Mauricio Tavares <[email protected]> > wrote: >> >> On Tue, Jul 5, 2011 at 2:31 PM, Kenneth Crocker <[email protected]> wrote: >> > Mauricio, >> > >> > What is it you want to do? It sounds like you want to put the last >> > correspondence of a ticket into an email/template when the owner of a >> > ticket >> > is changed. Is that right? Technically, there WAS a transaction record >> > created, but since it only involved an owner change, that's the only >> > info on >> > the transaction record. >> > >> > If this is what you want to do, it CAN be done fairly easily with a >> > scrip. >> > What you want to do is pull up the last comment transaction entered for >> > that >> > ticket. You can do that IN a template. >> > >> Well, this what I want do do: >> >> If ticket owner changed >> Send the last correspondence of a ticket into an email/template (as >> correspondence) to the new ticket owner. >> >> When I mean last correspondence I do want to include every attachment >> (.zip files, jpg, etc) it came with (like what you would get by >> having RT-Attach-Message: yes), not only the textual content (which is >> what you would get by doing $Transaction->Content). >> >> From what I understand, $Transaction->Content (and RT-Attach-Message: >> yes) need the last Transaction to be a correspondence type to do their >> magic. But since the transaction associated with owner changing does >> not generate a correspondence, I cannot use them as they are. Well, as >> you pointed out, getting the text part of the last correspondence and >> creating a correspondence with that as the content is, quite easy. The >> non-text attachments are causing me problems. >> >> In my test script I grabbed only the transactions in that ticket with >> correspondence in them and am able to see which attachments the last >> correspondence had. That really does not do me any good but at least >> made me feel happy that I was able to find the attachments. :) >> >> > Hope this helps. >> > >> > Kenn >> > LBNL >> > >> > On Thu, Jun 30, 2011 at 2:59 PM, Mauricio Tavares <[email protected]> >> > wrote: >> >> >> >> From what I understand (thanks trs), in an on Owner Change event >> >> you cannot rely on using {$Transaction->Content()} to copy the last >> >> message/correspondence in a given ticket because no transaction was >> >> created. So, how can you fake it in an template? If the content was >> >> only a text file, it is not hard to do it, but what happens when you >> >> also have attachments? I wrote the following template, >> >> >> >> { >> >> my $thingie = "Attachments:"; >> >> my $Transactions = $Ticket->Transactions; >> >> >> >> $Transactions->Limit( FIELD => 'Type', >> >> VALUE => "Correspond" >> >> ); >> >> # $Rt::Logger->debug("Find Transaction"); >> >> my $TransactionObj = $Transactions->Last; >> >> my $AttachmentsObj = >> >> RT::Attachments->new($TransactionObj->CurrentUser); >> >> $AttachmentsObj->Limit( FIELD => 'TransactionID', >> >> VALUE => $TransactionObj->id >> >> ); >> >> while ( my $a = $AttachmentsObj->Next ) { >> >> $thingie .= "\nFound an attachment with encoding " . >> >> $a->ContentType . " and ID " . $a->id; >> >> if ( $a->ContentType eq 'text/plain' || $a->ContentType eq >> >> 'text/html'){ >> >> $thingie .= "\nContent:\n" . $a->Content; >> >> } >> >> elseif ( $a->ContentType eq 'multipart/mixed') { >> >> } >> >> else { >> >> $thingie .= "\n" . $RT::WebURL ."/Ticket/Attachment/". >> >> $a->TransactionId ."/". $a->id ."/". $a->Filename; >> >> $thingie .= "\n "; >> >> } >> >> } >> >> $thingie; >> >> } >> >> >> >> which finds the attachments and put links for the non-text (from >> >> http://requesttracker.wikia.com/wiki/AddAttachmentLinksToMail) >> >> attachments, but what I really want is, well, emulate >> >> {$Transaction->Content()}. Would anyone have any pointers? >> >> >> >> -------- >> >> 2011 Training: http://bestpractical.com/services/training.html >> > >> > >> > >> > -------- >> > 2011 Training: http://bestpractical.com/services/training.html >> > > > > > -------- > 2011 Training: http://bestpractical.com/services/training.html > -------- 2011 Training: http://bestpractical.com/services/training.html
