Can title be the subject in email templates?

Moderator: crythias

Post Reply
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Can title be the subject in email templates?

Post by apolloit »

Hello All,

I wonder if the default email subject (when either replying, or using the outbound email button) can be forced to use the title of the ticket?

I'm looking in the templates area - and there is nowhere to change the subject.

Any help much appreciated. Have a great day :)

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

Re: Can title be the subject in email templates?

Post by RStraub »

Hey there,

the building of the subject is hardcoded, e.g. for responding (AgentTicketCompose) it's build with this code:

Code: Select all

        # prepare subject
        my $Tn = $Self->{TicketObject}->TicketNumberLookup( TicketID => $Self->{TicketID} );
        $GetParam{Subject} = $Self->{TicketObject}->TicketSubjectBuild(
            TicketNumber => $Tn,
            Subject      => $GetParam{Subject} || '',
        );
And finally sent with this code:

Code: Select all

        my $ArticleID = $Self->{TicketObject}->ArticleSend(
            ArticleTypeID  => $GetParam{ArticleTypeID},
            SenderType     => 'agent',
            TicketID       => $Self->{TicketID},
            HistoryType    => 'SendAnswer',
            HistoryComment => "\%\%$Recipients",
            From           => $GetParam{From},
            To             => $GetParam{To},
            Cc             => $GetParam{Cc},
            Bcc            => $GetParam{Bcc},
            Subject        => $GetParam{Subject},
            UserID         => $Self->{UserID},
            Body           => $GetParam{Body},
            InReplyTo      => $GetParam{InReplyTo},
            References     => $GetParam{References},
            Charset        => $Self->{LayoutObject}->{UserCharset},
            MimeType       => $MimeType,
            Attachment     => \@AttachmentData,
            %ArticleParam,
        );

So you'd have to customize the files to achieve that.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Re: Can title be the subject in email templates?

Post by apolloit »

Many thanks indeed for your kind reply. So quick!

I'd like to try changing this, but I'm not a confident coder. Would you mind letting me know the filename involved, and what you would change in there? I'm happy to back up the file and have a go at editing this.

All I want is the title to be reported in the subject (along with the normal ticket number).

Thanks again,

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

Re: Can title be the subject in email templates?

Post by RStraub »

Right, so first locate the file:

Code: Select all

$HOME/Kernel/Modules/AgentTicketCompose.pm
then copy it to the Custom folder (so upgrades don't overwrite your change):

Code: Select all

cp -p $HOME/Kernel/Modules/AgentTicketCompose.pm $HOME/Custom/Kernel/Modules/AgentTicketCompose.pm
you might need to create the folders first:

Code: Select all

mkdir -p $HOME/Custom/Kernel/Modules
Then open the file and search for the prepare subject part. Change this part:

Code: Select all

        my $Tn = $Self->{TicketObject}->TicketNumberLookup( TicketID => $Self->{TicketID} );
        $GetParam{Subject} = $Self->{TicketObject}->TicketSubjectBuild(
            TicketNumber => $Tn,
            Subject      => $GetParam{Subject} || '',
        );
to this part:

Code: Select all

        my %Ticket = $Self->{TicketObject}->TicketGet(
            TicketID      => $Self->{TicketID},
            DynamicFields => 0,
            UserID        => 1,
        );
        my $Tn = $Self->{TicketObject}->TicketNumberLookup( TicketID => $Self->{TicketID} );
        $GetParam{Subject} = $Self->{TicketObject}->TicketSubjectBuild(
            TicketNumber => $Tn,
            Subject      => $Ticket{Title} || '',
        );

This should work for version 4.x, don't have a test envirorment for 5 yet :)
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Re: Can title be the subject in email templates?

Post by apolloit »

Apologies for the delay sir. I really appreciate you explaining all that.

Having moved the pm file into the custom folder (which did exist), and editing it according to your instructions - everything worked like a charm.

Excellent help - and thank you :)

Have a Happy Christmas.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Can title be the subject in email templates?

Post by RStraub »

Glad to help :)
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Charmacas
Znuny advanced
Posts: 103
Joined: 18 Jan 2016, 10:27
Znuny Version: 5.0.26 on Debian 8

Re: Can title be the subject in email templates?

Post by Charmacas »

Did anyone test this for Framework 5?

I think this way is Really practical because even if I am writing a third party the mail should include the title.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Can title be the subject in email templates?

Post by jojo »

Use forward or reply
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Charmacas
Znuny advanced
Posts: 103
Joined: 18 Jan 2016, 10:27
Znuny Version: 5.0.26 on Debian 8

Re: Can title be the subject in email templates?

Post by Charmacas »

Of course you're right but why and when should I then use Outgoing eMail?
wurzel
Znuny guru
Posts: 3234
Joined: 08 Jul 2010, 22:25
Znuny Version: x.x.x
Real Name: Florian

Re: Can title be the subject in email templates?

Post by wurzel »

Hi

outgoing email is a new mail to 3rd party without involving the customer.

Flo
OTRS 8 SILVER (Prod)
OTRS 8 auf Debian 11 (Test)
Znuny 7.x latest version testing auf Debian 11

-- Ich beantworte keine Forums-Fragen PN - No PN please

I won't answer to unfriendly users any more. A greeting and regards are just polite.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Can title be the subject in email templates?

Post by reneeb »

You can use StdSubject from OPAR: http://opar.perl-services.de/dist/StdSubject
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Charmacas
Znuny advanced
Posts: 103
Joined: 18 Jan 2016, 10:27
Znuny Version: 5.0.26 on Debian 8

Re: Can title be the subject in email templates?

Post by Charmacas »

Thank you very much reneeb! This is exactly what I was looking for and so it perfectly fits.
Post Reply