Hi Eric,
ok. This file is using OTRS API 1.3. For OTRS 2.2 it's a little bit
different.
Anyway. Here is the diff and attached is a working version.
Many greetings from Straubing,
-Martin
#!/usr/bin/perl -w
# --
# create ticket with an article
# Copyright (C)
# --
# $Id: otrs.addUser,v 1.8 2003/03/06 22:11:59 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use lib dirname($RealBin)."/Kernel/cpan-lib";
use Kernel::Config;
use Kernel::System::Time;
use Kernel::System::Log;
use Kernel::System::Main;
use Kernel::System::DB;
use Kernel::System::Ticket;
my $ConfigObject = Kernel::Config->new();
my $LogObject = Kernel::System::Log->new(
ConfigObject => $ConfigObject,
LogPrefix => "CreateTicket.pl",
);
my $TimeObject = Kernel::System::Time->new(
LogObject => $LogObject,
ConfigObject => $ConfigObject,
);
my $MainObject = Kernel::System::Main->new(
LogObject => $LogObject,
ConfigObject => $ConfigObject,
);
my $DBObject = Kernel::System::DB->new(
ConfigObject => $ConfigObject,
LogObject => $LogObject,
MainObject => $MainObject,
);
my $TicketObject = Kernel::System::Ticket->new(
ConfigObject => $ConfigObject,
LogObject => $LogObject,
DBObject => $DBObject,
MainObject => $MainObject,
TimeObject => $TimeObject,
);
my $TicketID = $TicketObject->TicketCreate(
TN => $TicketObject->TicketCreateNumber(),
Queue => 'Raw',
Lock => 'unlock',
GroupID => 1,
Priority => '3 normal',
State => 'new',
CustomerNo => '',
CustomerUser => '',
OwnerID => 1, # current owner
UserID => 1,
);
print "Ticket (TicketID:$TicketID) created.\n";
if ($TicketID) {
my $ArticleID = $TicketObject->ArticleCreate(
TicketID => $TicketID,
ArticleType => 'note-external', # email-external|email-internal|phone|fax|...
SenderType => 'customer', # agent|system|customer
From => 'Some Agent <[EMAIL PROTECTED]>', # not required but useful
To => 'Some Customer A <[EMAIL PROTECTED]>', # not required but useful
Cc => 'Some Customer B <[EMAIL PROTECTED]>', # not required but useful
Subject => 'some short description', # required
Body => 'the message text', # required
ContentType => 'text/plain; charset=ISO-8859-15',
HistoryType => 'EmailCustomer', # EmailCustomer|Move|AddNote|PriorityUpdate|WebRequestCustomer|...
HistoryComment => 'Some free text!',
UserID => 1,
);
print "Article (ArticleID:$ArticleID) aded to TicketID $TicketID.\n";
}
exit (0);
[EMAIL PROTECTED]:~/src/otrs-cvs$ diff ~/Downloads/CreateTicket2-n.pl bin/
CreateTicket
20a21
> use Kernel::System::Main;
23a25,28
> my $LogObject = Kernel::System::Log->new(
> ConfigObject => $ConfigObject,
> LogPrefix => "CreateTicket.pl",
> );
28c33,34
< my $LogObject = Kernel::System::Log->new(
---
> my $MainObject = Kernel::System::Main->new(
> LogObject => $LogObject,
30d35
< LogPrefix => "CreateTicket.pl",
34a40
> MainObject => $MainObject,
39a46
> MainObject => $MainObject,
52,53c59,60
< UserID => 1, # current owner
< CreateUserID => 1,
---
> OwnerID => 1, # current owner
> UserID => 1,
[EMAIL PROTECTED]:~/src/otrs-cvs$
On Nov 23, 2007, at 4:50 PM, Partington, Eric wrote:
Here is the file as it stands now. My system is running RHEL4 OTRS
2.2.3
This is where I found the original file from 2004.
http://lists.otrs.org/pipermail/dev/2004-November/000802.html
Thanks for the help everyone.
Eric
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Martin Edenhofer
Sent: 2007, November, 23 9:23 AM
To: Development community of OTRS.org
Subject: Re: [dev] CreateTicket2-n.pl perl ticket interface OTRS 2.2.3
Hi Eric,
can you upload the file somewhere (so it's easier)? :)
-Martin
On Nov 23, 2007, at 3:04 PM, Partington, Eric wrote:
Thanks for the prompt response Martin,
I tried your suggestion and still have the same error that I did
before. Any more suggestions?
I also noticed that many of the modules are written with the
$CommonObject{} format as opposed to the $method format. Is
something
I should be looking into?
Eric
[EMAIL PROTECTED] bin]$ ./CreateTicket2-n.pl Got no LogObject! at
/opt/otrs/Kernel/System/Time.pm line 70, <PRODUCT> line 4.
The TimeObject needs also the LogObject as param like:
my $ConfigObject = Kernel::Config->new();
my $LogObject = Kernel::System::Log->new(
ConfigObject => $ConfigObject,
);
my $TimeObject = Kernel::System::Time->new(
LogObject => $LogObject,
ConfigObject => $ConfigObject,
);
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev