Help -- how to get message bodies from $Ticket object?

What the subject sayd. Specifically, I need to be able to
include the body of a message (either the first or the last
correspondence on a ticket) into the notification that goes out upon
queue change. I have been going over the code and the docs, and the one
datum I can’t figure out how to get from $Ticket, is the message bodies.

Can anyone help, please?

| Victor Danilchenko ±------------------------------------------+
| danilche@cs.umass.edu | If voting could really change the system, |
| CSCF | 5-4231 | it would be against the law. |

Victor Danilchenko a écrit :

What the subject sayd. Specifically, I need to be able to
include the body of a message (either the first or the last
correspondence on a ticket) into the notification that goes out upon
queue change. I have been going over the code and the docs, and the one
datum I can’t figure out how to get from $Ticket, is the message bodies.

Can anyone help, please?

I think messages are attached to transactions of tickets. Maybe should
you look at share/html/Ticket/Elements/ShowHistory and
share/html/Ticket/Elements/ShowTransaction, it might help.

Guillaume Perréal.

Responsable informatique,
Cemagref, groupement de Lyon,
France.

Tél: (+33) 4.72.20.87.87.
Fax: (+33) 4.78.47.78.75.
Site: http://www.lyon.cemagref.fr/

Victor Danilchenko a écrit :

What the subject sayd. Specifically, I need to be able to
include the body of a message (either the first or the last
correspondence on a ticket) into the notification that goes out upon
queue change. I have been going over the code and the docs, and the one
datum I can’t figure out how to get from $Ticket, is the message bodies.

Can anyone help, please?

I think messages are attached to transactions of tickets. Maybe should
you look at share/html/Ticket/Elements/ShowHistory and
share/html/Ticket/Elements/ShowTransaction, it might help.

Thanks. That was a good suggestion -- I found the Attachments

method for Transaction class. Unfortunately, it seems to return only the
attachments pertaining to that transaction – so if the transaction is
correspondence, I get valid attachments I can enumerate through
(Transaction->Attachments()->First() returns a value). However, if the
transaction is queue change, I get no attachments returned that way, and
that’s exactly when I need the attachments.

note the docs for Attachments_Overlay class have an interesting

statement:

“This module should never be called directly by client code. it’s an
internal module which should only be accessed through exported APIs in
Ticket, Queue and other similar objects.”

It sounds like there should be a way to access Attachments from

a Ticket object, which is exactly what I want – but there is no
Ticket::Attachments method, bnor anything resembling it!. I kept going
through the code, and i cannot find anything useful.

I am guessing that there has to be either a way to create

Attachments object initialized with the attachments for a given Ticket
object, or a way to just get the Attachments pbject returned by Ticker
object straight up. Any ideas on how to do it?

| Victor Danilchenko | Catch a man a fish, and you can sell it to him; |
| danilche@cs.umass.edu | teach him to fish, and you’ll ruin a wonderful |
| CSCF | 5-4231 | business opportunity. |

Well, i finally – after looking through the SQL table structure
– solved it. As is often the case, most of the answer was figuring out
the right question.

the following code in the template did the trick (it's

unfinished – no error handling yet):

{ my $tlist=$Ticket->Transactions();
my $trans=$tlist->First();
$tlist->GotoFirstItem();
while (my $t=$tlist->Next()){
$trans=$t if $t->Type =~ /correspond/i;
}
my $message=$trans->Attachments()->First()->Content();
"-------------------------------------------------------\n".
“Last correspondence was:\n\n”.$message;
}

| Victor Danilchenko | You cannot apply a technological |
| danilche@cs.umass.edu | solution to a sociological problem. |
| CSCF | 5-4231 | Edwards’ Law |