Create tickets per script

Hello,

I have to put a lot of datasets from the Keystone-Help-Desk System to RT.
Therefor I want to write Perl-Scripts. Now I´am testing how to write data
with scripts into rt using the rt-modules.
The content of tickets I makes problems to me.
The ticket-content is stored at attachments and is linked over the
transactions. First I tried it this way:

Modules which used

use RT::Tickets;
use MIME::Entity;

initialise Ticket-Object

my $ticket = RT::Ticket->new($RT::SystemUser);
my $ticketId = $ticket->Create( Queue => 6,
Requestor => 33,
Cc => 24,
AdminCC => 26,
Owner => 29,
Subject => ‘Test 4 mit perl’,
Starts => localtime(),
Priority => 20
MIMEObj => $mimeObj);

But I get always this error:
syntax error at /home/borsti/Documents/perl/RT_test/Ticket.pl line 34, near
"MIMEObj"
Execution of /home/borsti/Documents/perl/RT_test/Ticket.pl aborted due to
compilation errors.

Then I tried it this way. It works, but I think it is circumstantially.

Modules which used

use RT::Tickets;
use MIME::Entity;

initialise Ticket-Object

my $ticket = RT::Ticket->new($RT::SystemUser);

now I want to put the content in table Attachments

the only way: load the ticket and fetch its transactionId, a new ticket has

only the

transactionid to the transactiontype Create

load ticket, method return the id, also when put an id to the load-function

my $ticketId = $ticket->Load(39);
my $subject = $ticket->Subject();

get transactionId from ticket which transactiontype is Create

my $tTypeId = GetCreateTransactionId($ticketId);

create a new attachment to the transactionID

my $attachment = RT::Attachment->new($RT::SystemUser);

content are in a MIME::Entity

my $mimeObj = MIME::Entity->new();
$mimeObj->build(
Type => ‘text/plain’,
Data => ‘hoffentlich klappts’,
Subject => $subject);
my $attId = $attachment->Create(Attachment => $mimeObj, Parent => 0,
TransactionId => 115);

SUB

get Create-TransactionId from a Ticket, Takes a TicketId

sub GetCreateTransactionId {
my $tId = shift( @_ ); # uebergebende Id auslesen
my $transactions = RT::Transactions->new($RT::SystemUser); # new instance
of transactions
$transactions = $ticket->Transactions(); # fetch transactions to this
ticket
print( “Transactions zu Ticket ID = $ticketId sind: $transactions.\n” );

# now seperate the transactions, here I know that there is only one 

transaction, which type # is ‘Create’! Actually I have to control the
type of the transaction
my $transaction = $transactions->NewItem(); # new instance of transaction
$transaction = $transactions->Next();
while ($transaction != ()) {
my $taType = $transaction->Type();
if ($taType eq ‘Create’) {
my $id = $transaction->id();
return $id;
}
else {
return undef;
}
$transaction = $transactions->Next();
}
}

Can someone help me please? What is the simpliest way?

Greetings Tina

[Tina Schade]

my $ticketId = $ticket->Create( Queue => 6,
Requestor => 33,
Cc => 24,
AdminCC => 26,
Owner => 29,
Subject => ‘Test 4 mit perl’,
Starts => localtime(),
Priority => 20
MIMEObj => $mimeObj);

Missing comma after ‘20’ and ‘MIMEObj’.

But I get always this error:
syntax error at /home/borsti/Documents/perl/RT_test/Ticket.pl line 34, near
“MIMEObj”
Execution of /home/borsti/Documents/perl/RT_test/Ticket.pl aborted due to
compilation errors.

At least that is my guess based on this error message.