how to use articlecreate api

English! place to talk about development, programming and coding
Post Reply
jfberni
Znuny newbie
Posts: 17
Joined: 03 Mar 2011, 16:51
Znuny Version: 3.0

how to use articlecreate api

Post by jfberni »

Hello everyone,

I create a simple script using Articlecreate API ( use Kernel::System::Ticket::Article;).

First of all i try to add article using existing ticket. But i got msg error below :

Global symbol "$TicketObject" requires explicit package name at otrs1.pl line 18.
Global symbol "$ArticleID" requires explicit package name at otrs1.pl line 33.
syntax error at otrs1.pl line 35, near ");"
Execution of otrs1.pl aborted due to compilation errors.

Any tough ?

J-F

Code: Select all

***otrs.pl***
use strict;
use warnings;
use utf8;
use vars (qw($Self));
use lib "/opt/otrs/";
use lib "/opt/otrs/Kernel/cpan-lib";
use lib "/opt/otrs/Custom";
use Time::HiRes qw( usleep );
use Kernel::Config;
use Kernel::System::Ticket;
use Kernel::System::Ticket::Article;

 my $ArticleID = $TicketObject->ArticleCreate(
        TicketID         => 12859,
        ArticleType      => 'note-internal',
        SenderType       => 'agent',
        From             => 'Completed <no@reply.com>',
        To               => 'Some Customer A <customer-a@example.com>',
        Subject          => 'IP Adress ',
        Body             => 'IP adress ready',
        ContentType      => 'text/plain',
        HistoryType      => 'AddNote',
        HistoryComment   => 'IP adress added',
        UserID           => 123,
        NoAgentNotify    => 0,

$Self->True(
    $ArticleID,
    'ArticleCreate()',
);

***otrs.pl***
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: how to use articlecreate api

Post by crythias »

Global symbol "$TicketObject" requires explicit package name at otrs1.pl line 18.
Global symbol "$ArticleID" requires explicit package name at otrs1.pl line 33.

You did not define what a $TicketObject is, but you told $ArticleID to hold the result of a subroutine call from it.
http://dev.otrs.org/3.1/Kernel/System/Ticket.html

(read the example under new() on how to properly define the necessary parts of a TicketObject.)
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
jfberni
Znuny newbie
Posts: 17
Joined: 03 Mar 2011, 16:51
Znuny Version: 3.0

Re: how to use articlecreate api

Post by jfberni »

Thanks crythias for your update.
Post Reply