Skip to content

Commit

Permalink
Issue #4110: Copied dynamic field value HTML handling from ArticleCre…
Browse files Browse the repository at this point in the history
…ate transition action to TicketCreate.

Fixed typos.
  • Loading branch information
stefanhaerter committed Jan 31, 2025
1 parent e113ffc commit 2fda47f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ sub Run {
Behavior => 'IsHTMLContent',
);

# Avoid duble conversion to HTML for dynamic fields with HTML content.
# Avoid double conversion to HTML for dynamic fields with HTML content.
next MATCH if $IsHTMLContent;
$Param{Ticket}->{$Match} = $HTMLUtilsObject->ToHTML(
String => $Param{Ticket}->{$Match},
Expand Down
34 changes: 30 additions & 4 deletions Kernel/System/ProcessManagement/TransitionAction/TicketCreate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::DynamicField',
'Kernel::System::DynamicField::Backend',
'Kernel::System::HTMLUtils',
'Kernel::System::LinkObject',
'Kernel::System::Log',
'Kernel::System::State',
Expand Down Expand Up @@ -141,6 +142,35 @@ sub Run {
# override UserID if specified as a parameter in the TA config
$Param{UserID} = $Self->_OverrideUserID(%Param);

my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $DynamicFieldBackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');

# Convert DynamicField value to HTML string, see bug#14229.
my $HTMLUtilsObject = $Kernel::OM->Get('Kernel::System::HTMLUtils');
if ( $Param{Config}->{Body} =~ /OTOBO_TICKET_DynamicField_/ ) {
MATCH:
for my $Match ( sort keys %{ $Param{Ticket} } ) {
if ( $Match =~ m/DynamicField_(.*)/ && $Param{Ticket}->{$Match} ) {

my $DynamicFieldConfig = $DynamicFieldObject->DynamicFieldGet(
Name => $1,
);

# Check if there is HTML content.
my $IsHTMLContent = $DynamicFieldBackendObject->HasBehavior(
DynamicFieldConfig => $DynamicFieldConfig,
Behavior => 'IsHTMLContent',
);

# Avoid double conversion to HTML for dynamic fields with HTML content.
next MATCH if $IsHTMLContent;
$Param{Ticket}->{$Match} = $HTMLUtilsObject->ToHTML(
String => $Param{Ticket}->{$Match},
);
}
}
}

# use ticket attributes if needed
$Self->_ReplaceTicketAttributes(%Param);
$Self->_ReplaceAdditionalAttributes(%Param);
Expand Down Expand Up @@ -335,10 +365,6 @@ sub Run {
}
}

# get dynamic field objects
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $DynamicFieldBackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');

# get the dynamic fields for ticket
my $DynamicFieldList = $DynamicFieldObject->DynamicFieldListGet(
Valid => 1,
Expand Down

0 comments on commit 2fda47f

Please sign in to comment.