Kernel::System::LinkObject - to link objects like tickets, faq entries, ...
All functions to link objects like tickets, faq entries, ...
Don't use the constructor directly, use the ObjectManager instead:
my $LinkObject = $Kernel::OM->Get('Kernel::System::LinkObject');
return a hash of all possible types
Return %PossibleTypesList = ( 'Normal' => 1, 'ParentChild' => 1, );
my %PossibleTypesList = $LinkObject->PossibleTypesList( Object1 => 'Ticket', Object2 => 'FAQ', );
return a hash of all possible objects
Return %PossibleObjectsList = ( 'Ticket' => 1, 'FAQ' => 1, );
my %PossibleObjectsList = $LinkObject->PossibleObjectsList( Object => 'Ticket', );
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();
add a new link between two elements
$True = $LinkObject->LinkAdd( SourceObject => 'Ticket', SourceKey => '321', TargetObject => 'FAQ', TargetKey => '5', Type => 'ParentChild', State => 'Valid', UserID => 1, );
deletes old links from database
return true
$True = $LinkObject->LinkCleanup( State => 'Temporary', Age => ( 60 * 60 * 24 ), );
deletes a link
return true
$True = $LinkObject->LinkDelete( Object1 => 'Ticket', Key1 => '321', Object2 => 'FAQ', Key2 => '5', Type => 'Normal', UserID => 1, );
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 => 1, 212 => 1, 332 => 1, }, }, ParentChild => { Source => { 5 => 1, 9 => 1, }, Target => { 4 => 1, 8 => 1, 15 => 1, }, }, }, FAQ => { ParentChild => { Source => { 5 => 1, }, }, }, };
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, );
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, }, }, );
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, );
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, );
lookup a link object
$ObjectID = $LinkObject->ObjectLookup( Name => 'Ticket', ); or $Name = $LinkObject->ObjectLookup( ObjectID => 12, );
lookup a link type
$TypeID = $LinkObject->TypeLookup( Name => 'Normal', UserID => 1, ); or $Name = $LinkObject->TypeLookup( TypeID => 56, UserID => 1, );
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, );
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();
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();
return true if both types are NOT together in a type group
my $True = $LinkObject->PossibleType( Type1 => 'Normal', Type2 => 'ParentChild', );
lookup a link state
$StateID = $LinkObject->StateLookup( Name => 'Valid', ); or $Name = $LinkObject->StateLookup( StateID => 56, );
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) );
checks read permission for a given object and UserID.
$Permission = $LinkObject->ObjectPermission( Object => 'Ticket', Key => 123, UserID => 1, );
return a hash of object descriptions
Return %Description = ( Normal => '', Long => '', );
%Description = $LinkObject->ObjectDescriptionGet( Object => 'Ticket', Key => 123, UserID => 1, );
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, );
This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.