In the module of the TicketCreate event, i have TicketID of the Child Ticket!
How can i get the Parent TicketID of the Parent ticket?
My Code:
Code: Select all
sub new {
my ( $Type, %Param ) = @_;
my $Self = {};
bless( $Self, $Type );
$Self->{LinkObject} = Kernel::System::LinkObject->new(%Param);
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Data Event Config)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log(
Priority => 'error',
Message => "Need $_!"
);
return;
}
}
if ($Param{Event} eq 'TicketCreate') {
my $TicketID = $Param{Data}->{TicketID}; # Now, we have child TicketID.
my %LinkList = $Self->{LinkObject}->LinkKeyListWithData(
Object1 => 'Ticket',
Key1 => $Param{Data}->{TicketID}, #child TicketID
Object2 => 'Ticket',
Type => 'ParentChild',
Direction => 'Source',
State => 'Valid',
UserID => 1,
);
if (%LinkList) { # is empty :(
my $filename = "/usr/local/otrs/Custom/Kernel/summary.txt";
open(my $fh, '>', $filename) or die "Cant open.";
print $fh "Parent Ticket found.";
close $fh;
}
}
return 1;
}
Any ideas?