The requirement wants to update state for parent ticket when the state of child ticket is updated. For example, I have a parent ticket and a child ticket (split to create), the states of both are "new". When I update state of child ticket is "open" => auto update state of parent is "open" as well.
My current development, I'm using event of TicketStateUpdate (create an event file is *.pm in \Kernel\Ticket\Event\ and a config file to catch this event). So, when update a state of ticket, everything in event file will be implemented.
And my issue is how to prevent updating of state run in multi sub level in paren/child ticket. For example, there is a parent <- a child ticket <- a sub child ticket <- a sub sub child ticket, when update state of a sub sub child ticket, JUST ALLOW to update one level up for state of a sub child ticket. DO NOT allow to update state of a child ticket/ parent child.
Here is my coding in event file
Code: Select all
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 'TicketStateUpdate' ) {
# check existing parent tickets
my %LinkList = $Self->{LinkObject}->LinkKeyListWithData(
Object1 => 'Ticket',
Key1 => $Param{Data}->{TicketID},
Object2 => 'Ticket',
Type => 'ParentChild',
Direction => 'Source',
State => 'Valid',
UserID => 1,
);
if (%LinkList) {
# get child ticket
my %ChildTicket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
UserID => $Param{UserID},
);
# update state foreach parent ticket
for my $ParentTicketID ( keys %LinkList ) {
if ($ChildTicket{State}) {
$Self->{TicketObject}->TicketStateSet(
TicketID => $ParentTicketID,
State => $ChildTicket{State},
UserID => 1,
);
}
}
}
}
return 1;
}
Thanks in adv
Vu Nguyen