Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/check if all children are closed #206

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ sub new {
sub Validate {
my ( $Self, %Param ) = @_;

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

for my $Needed (qw(Data)) {
if ( !defined $Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Expand All @@ -90,15 +92,15 @@ sub Validate {
return;
}

# linked tickets
my $Links = $Kernel::OM->Get('Kernel::System::LinkObject')->LinkList(
Object => 'Ticket',
Object2 => 'Ticket',
Key => $Param{Data}{TicketID},
State => 'Valid',
Type => 'ParentChild',
UserID => 1,
);
my $Links = $LinkObject->LinkList(
Object => 'Ticket',
Key => $Param{Data}{TicketID},
Object2 => 'Ticket', # (optional)
State => 'Valid',
#Type => ''ParentChild'', # (optional)
Direction => 'Target', # (optional) default Both (Source|Target|Both)
UserID => 1,
);

if ( $Links
&& $Links->{Ticket}
Expand Down
38 changes: 24 additions & 14 deletions Kernel/System/Ticket/Event/InformClosedChildToParent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,35 @@ sub Run {

# create article for the parent
my $ChildTicketNumber = $TicketHook.$TicketHookDivider.$Ticket{TicketNumber};
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Phone' );
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Internal' );
$ParentArticleID = $ArticleBackendObject->ArticleCreate(
TicketID => $TicketID,
SenderType => 'system',
ArticleTypeID => 11, # note-report
Subject => $LayoutObject->{LanguageObject}->Translate(
'Child ticket closed: %s',
$ChildTicketNumber
),
Body => $LayoutObject->{LanguageObject}
IsVisibleForCustomer => 0,
MimeType => 'text/plain',
From => 'root@localhost',
InReplyTo => '',
NoAgentNotify => 0,
ReplyTo => '',
Body => $LayoutObject->{LanguageObject}
->Translate('A child ticket has been closed, please check it: %s.',
$ChildTicketNumber),
From => 'root@localhost',
ContentType => 'text/plain; charset=UTF-8',
UserID => 1,
HistoryType => 'AddNote',
Charset => 'utf-8',
UserID => 1,
Subject => $LayoutObject->{LanguageObject}->Translate(
'Child ticket closed: %s',
$ChildTicketNumber,
),
Cc => '',
To => '',
ContentType => 'text/plain; charset=utf-8',
HistoryComment => "Child ticket $Ticket{TicketNumber} closed.",
SenderTypeID => '2',
References => '',
Bcc => '',
SenderType => 'system',
MessageID => '',
HistoryType => 'AddNote',
TicketID => $TicketID
);

if ( !$ParentArticleID ) {
return $LayoutObject->ErrorScreen();
}
Expand Down