Kernel::System::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()

Builds a hash of all possible types for the given object combination.

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

Return

    %PossibleTypesList = (
        'Normal'      => 1,
        'ParentChild' => 1,
    );

PossibleObjectsList()

return a hash of all possible objects

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

    or

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

Return %PossibleObjectsList = ( 'Ticket' => 1, 'FAQ' => 1, );

return a 2 dimensional hash list of all possible links

Return %PossibleLinkList = ( 001 => { Object1 => 'Ticket', Object2 => 'Ticket', Type => 'Normal', }, 002 => { Object1 => 'Ticket', Object2 => 'Ticket', Type => 'ParentChild', }, );

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

LinkAdd()

add a new link between two elements

    my $LinkID = $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 ),
    );

LinkGet()

Returns a hash with link data for the given link id.

    my %LinkData = $LinkObject->LinkGet(
        LinkID => 4,
        UserID => 1,
    );

The returned hash contains the following elements:

    $LinkData{LinkID}
    $LinkData{SourceObjectID}
    $LinkData{SourceObject}
    $Existing{SourceKey}
    $LinkData{TargetObjectID}
    $LinkData{TargetObject}
    $LinkData{TargetKey}
    $LinkData{TypeID}
    $LinkData{Type}
    $LinkData{StateID}
    $LinkData{State}
    $LinkData{CreateTime}
    $LinkData{CreateBy}

LinkDelete()

deletes a link

return true

    $True = $LinkObject->LinkDelete(
        LinkID => 5,
        UserID => 1,
    );

LinkDeleteAll()

delete all links of an object

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

get all existing links for a given object

Return $LinkList = { Ticket => { Normal => { Source => { 12 => 198, # The value is the LinkID. 212 => 5, 332 => 7, }, }, ParentChild => { Source => { 5 => 3, 9 => 9, }, Target => { 4 => 14, 8 => 4, 15 => 8, }, }, }, FAQ => { ParentChild => { Source => { 5 => 89, }, }, }, };

    my $LinkList = $LinkObject->LinkList(
        Object    => 'Ticket',
        Key       => '321',
        Object2   => 'FAQ',         # (optional)
        State     => 'Valid',
        Type      => 'ParentChild', # (optional)
        Direction => 'Target',      # (optional) default Both (Source|Target|Both)
        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)
    );

BuildObjectTitleString()

Builds the object title string with the given object data.

    $BuildObjectTitleString = $LinkObject->BuildObjectTitleString(
        Object => 'Ticket',
        Data => { ... },
    );

Return

    $BuildObjectTitleString = 'Service#123: Example';

ObjectTypeNameForFrontend()

Gives the object type name for the frontend from the different backends. Normally it's the same, but in same cases it's different.

    $ObjectTypeNameForFrontend = $LinkObject->ObjectTypeNameForFrontend(
        Object  => 'FAQ',
    );

Return

    $ObjectTypeNameForFrontend = 'KnowledgeBaseArticle';

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,
    );
Scroll to Top