how can I create ticket by insert?

English! place to talk about development, programming and coding
Post Reply
cris12345
Znuny advanced
Posts: 105
Joined: 24 Feb 2017, 16:45
Znuny Version: 5.0.16.01
Real Name: Cristina Corrales
Company: -

how can I create ticket by insert?

Post by cris12345 »

Hi,
I need to upload some information as ticket.
What is needed to be considered in order to create a ticket by insert statement?

For example, the way ticket_history table is populate
or the way I can save the close time if ticket_history is not been populating after the insert ticket creation.

Thanks
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: how can I create ticket by insert?

Post by jojo »

don't do it. Use the webservice or the PERL API
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
cris12345
Znuny advanced
Posts: 105
Joined: 24 Feb 2017, 16:45
Znuny Version: 5.0.16.01
Real Name: Cristina Corrales
Company: -

Re: how can I create ticket by insert?

Post by cris12345 »

The reason is because the tickets will be created by a customer and comes form another system, so the idea is save the other system tickets in a excel file and do an upload...
How I can use the PERL API?
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: how can I create ticket by insert?

Post by RStraub »

Hey there,

you can view the API here:
http://doc.otrs.com/doc/api/otrs/5.0/Perl/index.html

A small standalone script which can be used directly from the console could look like this:

Code: Select all

#!/usr/bin/perl

use strict;
use warnings;
use utf8;

use lib '/opt/otrs/';
use lib '/opt/otrs/Kernel/cpan-lib';
use lib '/opt/otrs/Custom';

use Kernel::System::ObjectManager;

local $Kernel::OM = Kernel::System::ObjectManager->new(
    'Kernel::System::Log' => {
        LogPrefix => 'CreateTicket',
    },
);

my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

my $TicketID = $TicketObject->TicketCreate(
    Title        => 'Locally generated ticket',
    Queue        => 'Raw',            # or QueueID => 123,
    Lock         => 'unlock',
    Priority     => '3 normal',       # or PriorityID => 2,
    State        => 'new',            # or StateID => 5,
    CustomerID   => '123465',
    CustomerUser => 'customer@example.com',
    OwnerID      => 3,
    UserID       => 1,
);

1
Please note that this only creates a ticket. You might want to add an article as well.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Post Reply