[rt-users] Exporting request contents

Todd Chapman todd at chaka.net
Mon Jan 14 11:27:50 EST 2008


Stick with text. If you hack RT to export ticket history ( I have ) you will
quickly run into excel size limits, such as the number of characters that
can be stored in a cell.

Here's how I hacked RT so that I could get ticket history in search results
so that they could be exported:

In
/opt/rt3/local/html/Callbacks/myCompnay/Elements/RT__Ticket/ColumnMap/ColumnMap:

$COLUMN_MAP->{AllCorrespondence} = {
        title     => 'All Correspondence',
        attribute => 'AllCorrespondence',
        value     => sub { return $_[0]->AllCorrespondence },
};

In Ticket_Local.pm:

sub AllCorrespondenceTransactions {

    my $self = shift;
    my $role = shift;

    my $transactions = $self->Transactions;
    $transactions->Limit( SUBCLAUSE => 'type', FIELD => 'Type', VALUE    =>
'Create' );
    $transactions->Limit( SUBCLAUSE => 'type', FIELD => 'Type', VALUE    =>
'Correspond', ENTRYAGGREGATOR => 'OR' );

    if ( $role eq 'Requestor' ) {
        my $requestor_group = $self->Requestors;
        my $users = $requestor_group->UserMembersObj;
        while ( my $user = $users->Next ) {
            $transactions->Limit( SUBCLAUSE => 'requestors', FIELD =>
'Creator',
                                  VALUE => $user->PrincipalId,
ENTRYAGGREGATOR => 'OR' );
        }
    }
    elsif ( $role eq 'Owner' ) {
        $transactions->Limit( FIELD => 'Creator', VALUE =>
$self->OwnerObj->PrincipalId, ENTRYAGGREGATOR => 'AND' );
    }

    return $transactions;;

}

sub AllCorrespondence {

    my $self = shift;
    my $role = shift;

    my $transactions = $self->AllCorrespondenceTransactions($role);

    my $string = '';

    while ( my $t = $transactions->Next ) {
        $string .= "\n\n" . formatted($t);
    }

    return $string;

}

sub formatted {

    my $transaction = shift;
    return '' unless $transaction;

    my $string = '###### On ' . $transaction->CreatedObj->AsString . ' ' .
$transaction->CreatorObj->EmailAddress . " wrote:\n\n";
    $string .= $transaction->Content;

    return $string;

}

-Todd


On 1/10/08, Prasad Deshpande <prasaddeshpande at bajajfinance.in> wrote:
>
> Hi,
>
> We are using RT 3.2.3 on Red Hat 9. We would like export the existing
> data in a text or excel file. To do this, we have tried using the Query
> builder. We are able to export the data but we could not find the field
> to export ticket history ( ie. communication captured during the life
> cycle of the ticket).
>
> If somebody knows how to capture the ticket history then please let me
> know.
>
> Thanks in Advance
>
> Regards,
> Regards,
> Prasad Deshpande
> IT Department
> Phone: +91 20 27407157
> Ext: 7157
>
>
>
> DISCLAIMER:
> This message,including any attachments contains confidential and
> privileged information for the sole use of the intended recipient(s), and is
> protected by law. If you are not the intended recipient, please destroy all
> copies of the original message. Any unauthorized review, use, disclosure,
> dissemination, forwarding, printing or copying of this email or any action
> taken in reliance on this e-mail is strictly prohibited and may be unlawful.
> Bajaj Auto reserves the right to record, monitor, and inspect all email
> communications through its internal and external networks. Your messages
> shall be subject to such lawful supervision as Bajaj Auto deems necessary in
> order to protect its information, interests and reputation. Bajaj Auto
> prohibits and takes steps to prevent its information systems from being used
> to view, store or forward offensive or discriminatory material. If this
> message contains such material, please report it to abuse at bajajauto.co.in.
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20080114/3e781680/attachment.htm>


More information about the rt-users mailing list