Howto get ticket body
Imagine you need to get a body of some ticket. It isn’t so easy do to in RT. All its objects look like sets of nesting dolls :). Each of them contains link to one or more others.
In the our example, the ticket body is stored as attache. So, there is a simple diagram of object’s releastions:
Ticket --> List of Transactions --> Transaction --> List of Attachments --> Attachment
In that way we should make following processing to get the body of ticket:
my $list_trnxs = $ticket_obj->Transactions; while(my $trnx = $list_trnxs->Next) { next if $trnx->Type ne 'Create'; my $attachments = $trnx->Attachments; while(my $message = $attachments->Next) { unless($message->Parent) { print "Ticket body is: " . $message->Content; } } }
Don’t forget to call initialization RT method!