Process Ticket - Dynamic Field Value in Transition Action

Moderator: crythias

Locked
mmesnjak
Znuny newbie
Posts: 9
Joined: 21 May 2015, 10:16
Znuny Version: 4.0.11

Process Ticket - Dynamic Field Value in Transition Action

Post by mmesnjak »

Hi,

I need assistance with a process I'm constructing...

In a process, a new note is created in a transition action.
I want to add a Dynamic Field value that is already set (in the submitting Activity Dialog) to the Subject or the Body of the newly created note.

How do I reference that value?
How do I construct text that is:

Code: Select all

"some fixed text" + $value + "some other fixed text"
?
Is that even possible?

You can find a screenshot of the TA in the attachment.

Thanks!
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Process Ticket - Dynamic Field Value in Transition Action

Post by RStraub »

From 5.x onwards OTRS seems to understand smarttags in transition actions. So you could try with those.

As we needed this for version 4, we wrote a custom transition action that does exactly what you want:

Code: Select all

package Kernel::System::ProcessManagement::TransitionAction::CustomTitleSet;

use strict;
use warnings;
use utf8;

use Kernel::System::VariableCheck qw(:all);

use base qw(Kernel::System::ProcessManagement::TransitionAction::Base);

our @ObjectDependencies = (
    'Kernel::System::Log',
    'Kernel::System::Ticket',
    'Kernel::System::ITSMConfigItem',
);

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    return $Self;
}
sub Run {
    my ( $Self, %Param ) = @_;

    # define a common message to output in case of any error
    my $CommonMessage = "Process: $Param{ProcessEntityID} Activity: $Param{ActivityEntityID}"
        . " Transition: $Param{TransitionEntityID}"
        . " TransitionAction: $Param{TransitionActionEntityID} - ";

    # check for missing or wrong params
    my $Success = $Self->_CheckParams(
        %Param,
        CommonMessage => $CommonMessage,
    );
    return if !$Success;

    # override UserID if specified as a parameter in the TA config
    $Param{UserID} = $Self->_OverrideUserID(%Param);

    # use ticket attributes if needed
    $Self->_ReplaceTicketAttributes(%Param);

    # Check for required parameters in ConfigHash
    if ( !defined $Param{Config}->{Title} ) {
        $Kernel::OM->Get('Kernel::System::Log')->Log(
            Priority => 'error',
            Message  => $CommonMessage . "No Title configured!",
        );
        return;
    }

    $Success = 0;

    if (
        $Param{Config}->{Title} eq 'CustomTitleSet'
        )
    {
        $Success = $Kernel::OM->Get('Kernel::System::Ticket')->TicketTitleUpdate(
            Title    => "some fixed text" . $SomeVariable . "Some fixed text",
            TicketID => $Param{Ticket}->{TicketID},
            UserID   => $Param{UserID},
        );
    }
    else {

        # data is the same as in ticket nothing to do
        $Success = 1;
    }

    if ( !$Success ) {
        $Kernel::OM->Get('Kernel::System::Log')->Log(
            Priority => 'error',
            Message  => $CommonMessage
                . 'Ticket title could not be updated for Ticket: '
                . $Param{Ticket}->{TicketID} . '!',
        );
        return;
    }

    return 1;
}

1;

Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Process Ticket - Dynamic Field Value in Transition Action

Post by crythias »

Body:

Code: Select all

MyField is <OTRS_TICKET_DynamicField_MyField> and it will show in this line.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Locked