LinkObject

English! place to talk about development, programming and coding
Post Reply
Cody
Znuny newbie
Posts: 6
Joined: 01 Sep 2010, 11:44
Znuny Version: 2.4.7

LinkObject

Post by Cody »

Hi all,

i want to write a script which automatically links ConfigItem objects. In the first step i want to search all created Objects from the ConfigItem "Computer". In the Developer API for OTRS 2.4 I have found Kernel::System::LinkObject which i think can provide me the needed data.

If I run this script:

Code: Select all

#!/usr/bin/perl -w

use strict;
use warnings;

use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use lib dirname($RealBin) . '/Kernel/cpan-lib';

        use Kernel::Config;
        use Kernel::System::Encode;
        use Kernel::System::Log;
        use Kernel::System::Main;
        use Kernel::System::Time;
        use Kernel::System::DB;
        use Kernel::System::LinkObject;

        my $ConfigObject = Kernel::Config->new();
        my $EncodeObject = Kernel::System::Encode->new(
            ConfigObject => $ConfigObject,
        );
        my $LogObject = Kernel::System::Log->new(
            ConfigObject => $ConfigObject,
            EncodeObject => $EncodeObject,
        );
        my $MainObject = Kernel::System::Main->new(
            ConfigObject => $ConfigObject,
            EncodeObject => $EncodeObject,
            LogObject    => $LogObject,
        );
        my $TimeObject = Kernel::System::Time->new(
            ConfigObject => $ConfigObject,
            LogObject    => $LogObject,
        );
        my $DBObject = Kernel::System::DB->new(
            ConfigObject => $ConfigObject,
            EncodeObject => $EncodeObject,
            LogObject    => $LogObject,
            MainObject   => $MainObject,
        );
        my $LinkObject = Kernel::System::LinkObject->new(
            ConfigObject => $ConfigObject,
            LogObject    => $LogObject,
            DBObject     => $DBObject,
            TimeObject   => $TimeObject,
            MainObject   => $MainObject,
            EncodeObject => $EncodeObject,
        );

my $ObjectList = $LinkObject->ObjectSearch(
        Object       => 'ITSMConfigItem',
        SubObject    => 'Computer',         # (optional)
        UserID       => 1,
    );

1;
I get this error:
DBD::mysql::st execute failed: Unknown column 'Computer' in 'where clause' at /opt/otrs/Kernel/System/DB.pm line 559.
ERROR: ?LogPrefix?-10 Perl: 5.8.8 OS: linux Time: Tue Mar 1 13:40:20 2011

Message: Unknown column 'Computer' in 'where clause', SQL: 'SELECT id FROM configitem WHERE class_id IN (Computer) ORDER BY configitem_number, id ASC'

Traceback (21979):
Module: Kernel::System::ITSMConfigItem::ConfigItemSearch (v1.28) Line: 854
Module: Kernel::System::ITSMConfigItem::ConfigItemSearchExtended (v1.28) Line: 619
Module: Kernel::System::LinkObject::ITSMConfigItem::ObjectSearch (v1.15) Line: 237
Module: Kernel::System::LinkObject::ObjectSearch (v1.52.2.1) Line: 2294
Module: ConfigItemLink.pl (unknown version) Line: 74

DBD::mysql::st fetchrow_array failed: fetch() without execute() at /opt/otrs/Kernel/System/DB.pm line 622.
The ConfigItem Computer exists and it seems that there is a problem with the sql-query in some of the OTRS Perl-Modules.

I would be thankful for some help to get this script work.

Greets
Cody
OTRS::ITSM 2.1.1
Powerd by OTRS 2.4.9

CentOS 5.5
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: LinkObject

Post by jojo »

"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
Post Reply