LinkObject#

NAME#

Kernel::System::LinkObject - to link objects like tickets, faq entries, …

DESCRIPTION#

All functions to link objects like tickets, faq entries, …

PUBLIC INTERFACE#

new()#

Don’t use the constructor directly, use the ObjectManager instead:

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

PossibleTypesList()#

return a hash of all possible types

Return
%PossibleTypesList = (

‘Normal’ => 1, ‘ParentChild’ => 1,

);

my %PossibleTypesList = $LinkObject->PossibleTypesList(
    Object1 => 'Ticket',
    Object2 => 'FAQ',
);

PossibleObjectsList()#

return a hash of all possible objects

Return
%PossibleObjectsList = (

‘Ticket’ => 1, ‘FAQ’ => 1,

);

my %PossibleObjectsList = $LinkObject->PossibleObjectsList(
    Object => 'Ticket',
);

LinkAdd()#

add a new link between two elements

$True = $LinkObject->LinkAdd(
    SourceObject => 'Ticket',
    SourceKey    => '321',
    TargetObject => 'FAQ',
    TargetKey    => '5',
    Type         => 'ParentChild',
    State        => 'Valid',
    UserID       => 1,
);

LinkCleanup()#

deletes old links from database

return true

$True = $LinkObject->LinkCleanup(
    State => 'Temporary',
    Age   => ( 60 * 60 * 24 ),
);

LinkDelete()#

deletes a link

return true

$True = $LinkObject->LinkDelete(
    Object1 => 'Ticket',
    Key1    => '321',
    Object2 => 'FAQ',
    Key2    => '5',
    Type    => 'Normal',
    UserID  => 1,
);

LinkDeleteAll()#

delete all links of an object

$True = $LinkObject->LinkDeleteAll(
    Object => 'Ticket',
    Key    => '321',
    UserID => 1,
);

LinkListWithData()#

get all existing links for a given object with data of the other objects

Return
$LinkList = {
Ticket => {
Normal => {
Source => {

12 => $DataOfItem12, 212 => $DataOfItem212, 332 => $DataOfItem332,

},

}, ParentChild => {

Source => {

5 => $DataOfItem5, 9 => $DataOfItem9,

}, Target => {

4 => $DataOfItem4, 8 => $DataOfItem8, 15 => $DataOfItem15,

},

},

}, FAQ => {

ParentChild => {
Source => {

5 => $DataOfItem5,

},

},

},

};

my $LinkList = $LinkObject->LinkListWithData(
    Object           => 'Ticket',
    Key              => '321',
    Object2          => 'FAQ',         # (optional)
    State            => 'Valid',
    Type             => 'ParentChild', # (optional)
    Direction        => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID           => 1,
    ObjectParameters => {              # (optional) backend specific flags
        Ticket => {
            IgnoreLinkedTicketStateTypes => 0|1,
        },
    },
);

LinkKeyList()#

return a hash with all existing links of a given object

Return
%LinkKeyList = (

5 => 1, 9 => 1, 12 => 1, 212 => 1, 332 => 1,

);

my %LinkKeyList = $LinkObject->LinkKeyList(
    Object1   => 'Ticket',
    Key1      => '321',
    Object2   => 'FAQ',
    State     => 'Valid',
    Type      => 'ParentChild', # (optional)
    Direction => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID    => 1,
);

LinkKeyListWithData()#

return a hash with all existing links of a given object

Return
%LinkKeyList = (

5 => $DataOfItem5, 9 => $DataOfItem9, 12 => $DataOfItem12, 212 => $DataOfItem212, 332 => $DataOfItem332,

);

my %LinkKeyList = $LinkObject->LinkKeyListWithData(
    Object1   => 'Ticket',
    Key1      => '321',
    Object2   => 'FAQ',
    State     => 'Valid',
    Type      => 'ParentChild', # (optional)
    Direction => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID    => 1,
);

ObjectLookup()#

lookup a link object

$ObjectID = $LinkObject->ObjectLookup(
    Name => 'Ticket',
);

or

$Name = $LinkObject->ObjectLookup(
    ObjectID => 12,
);

TypeLookup()#

lookup a link type

$TypeID = $LinkObject->TypeLookup(
    Name   => 'Normal',
    UserID => 1,
);

or

$Name = $LinkObject->TypeLookup(
    TypeID => 56,
    UserID => 1,
);

TypeGet()#

get a link type

Return

$TypeData{TypeID} $TypeData{Name} $TypeData{SourceName} $TypeData{TargetName} $TypeData{Pointed} $TypeData{CreateTime} $TypeData{CreateBy} $TypeData{ChangeTime} $TypeData{ChangeBy}

%TypeData = $LinkObject->TypeGet(
    TypeID => 444,
);

TypeList()#

return a 2 dimensional hash list of all valid link types

Return
$TypeList{
Normal => {

SourceName => ‘Normal’, TargetName => ‘Normal’,

}, ParentChild => {

SourceName => ‘Parent’, TargetName => ‘Child’,

},

}

my %TypeList = $LinkObject->TypeList();

TypeGroupList()#

return a 2 dimensional hash list of all type groups

Return
%TypeGroupList = (
001 => [

‘Normal’, ‘ParentChild’,

], 002 => [

‘Normal’, ‘DependsOn’,

], 003 => [

‘ParentChild’, ‘RelevantTo’,

],

);

my %TypeGroupList = $LinkObject->TypeGroupList();

PossibleType()#

return true if both types are NOT together in a type group

my $True = $LinkObject->PossibleType(
    Type1 => 'Normal',
    Type2 => 'ParentChild',
);

StateLookup()#

lookup a link state

$StateID = $LinkObject->StateLookup(
    Name => 'Valid',
);

or

$Name = $LinkObject->StateLookup(
    StateID => 56,
);

StateList()#

return a hash list of all valid link states

Return
$StateList{

4 => ‘Valid’, 8 => ‘Temporary’,

}

my %StateList = $LinkObject->StateList(
    Valid => 0,   # (optional) default 1 (0|1)
);

ObjectPermission()#

checks read permission for a given object and UserID.

$Permission = $LinkObject->ObjectPermission(
    Object => 'Ticket',
    Key    => 123,
    UserID => 1,
);

ObjectDescriptionGet()#

return a hash of object descriptions

Return
%Description = (

Normal => ‘’, Long => ‘’,

);

%Description = $LinkObject->ObjectDescriptionGet(
    Object => 'Ticket',
    Key    => 123,
    UserID => 1,
);

ObjectSearch()#

return a hash reference of the search results.

Returns:

$ObjectList = {
    Ticket => {
        NOTLINKED => {
            Source => {
                12  => $DataOfItem12,
                212 => $DataOfItem212,
                332 => $DataOfItem332,
            },
        },
    },
};

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