Add Customer Name to Email Subject

Moderator: crythias

Locked
ipmanux
Znuny newbie
Posts: 10
Joined: 12 Oct 2011, 11:42
Znuny Version: 3.0.7

Add Customer Name to Email Subject

Post by ipmanux »

Dear All,

How to add the customer Name to the email Subject of the Responses ?

Actually there is only the ticket number and ticket tile.

Regards,
OTRS 3.0.9, Mysql, Centos
ipmanux
Znuny newbie
Posts: 10
Joined: 12 Oct 2011, 11:42
Znuny Version: 3.0.7

Re: Add Customer Name to Email Subject

Post by ipmanux »

What i am looking for is when I send an email from a ticket, i would like that in the Email Subject we see the Ticket Number, Customer Name and Ticket Title

Rgds,
OTRS 3.0.9, Mysql, Centos
otrs-warrior
Znuny newbie
Posts: 5
Joined: 13 Oct 2011, 19:28
Znuny Version: 3.0.4
Real Name: Georges

Re: Add Customer Name to Email Subject

Post by otrs-warrior »

Hello,

I am trying to do the same here, to find a way to add "Customer Company name" or "CustomerID" automatically in the Ticket Subject upon an email update.

The following tag already exist in OTRS: <OTRS_TICKET_CustomerID> but no tag for the Company Name...
I have tried to insert the previous tag into the ticket hook (Ticket > Core::Ticket > Ticket::Hook), but without success.

Note: Having Customer Company Name in ticket subject is crucial for organizing users & agents mail-boxes (as they most use incoming filters...) as well as for quickly identifying the customer involved with a ticket follow-up upon a quick email check. And it would be also great if we can add ticket Priority as well.

Thanks in advance for any help.
OTRS::ITSM 3.0.10 on Linux with MySQL database.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add Customer Name to Email Subject

Post by crythias »

You might be able to modify Ticket.pm. We generally figure the from address relates to the customer...
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
otrs-warrior
Znuny newbie
Posts: 5
Joined: 13 Oct 2011, 19:28
Znuny Version: 3.0.4
Real Name: Georges

Re: Add Customer Name to Email Subject

Post by otrs-warrior »

Crythias, thanks for the hint.

I am now able to add static text to the Subject by editing the return clauses in TicketSubjectBuild subroutine.
i.e: return "[$TicketHook$TicketHookDivider$Param{TicketNumber}] " . "STATIC TEXT HERE - " . $Subject;

But it seems other ticket information is missing from the $Param array.. the only information available is Ticket Number, Subject, and Type.

I also found that TicketSubjectBuild is called from the module AgentTicketEmail.pm... Is there any guide explaining how the code works and how to modify it?

Thanks
OTRS::ITSM 3.0.10 on Linux with MySQL database.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add Customer Name to Email Subject

Post by crythias »

$Param{CustomerID} doesn't work?

If you want the Customer Company, you'll have to add

Code: Select all

use Kernel::System::CustomerCompany;
CustomerCompanyGet()
get customer company attributes

Code: Select all

my %CustomerCompany;
if ($Param{CustomerID}) {
    %CustomerCompany = $CustomerCompanyObject->CustomerCompanyGet(
        CustomerID => $Param{CustomerID},
    );
}
then

Code: Select all

. $CustomerCompany{CustomerCompanyName}.
Nothing tested, but it should get you on your way.
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
otrs-warrior
Znuny newbie
Posts: 5
Joined: 13 Oct 2011, 19:28
Znuny Version: 3.0.4
Real Name: Georges

Re: Add Customer Name to Email Subject

Post by otrs-warrior »

in Ticket.pm and within the subroutine TicketSubjectBuild(), $Param{CustomerID} doesn't work.. no value returned
$Param only holds ticket number, subject, and type (reply, new, forward)
OTRS::ITSM 3.0.10 on Linux with MySQL database.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add Customer Name to Email Subject

Post by crythias »

$Self is a Ticket Object

Code: Select all

my $TicketID = $Self->TicketIDLookup(
   TicketNUmber => $Param{TicketNumber},
   UserID => 1,
);
my %Ticket = $Self->TicketGet(
   TicketID => $TicketID,
   UserID =>1,
);
$Param{CustomerID} = $Ticket{CustomerID};
... other stuff previously posted.

Again, not tested, but this is based upon the API. If it doesn't work, it may be something syntax error, but if I understood the code, this is close.
otrs-warrior
Znuny newbie
Posts: 5
Joined: 13 Oct 2011, 19:28
Znuny Version: 3.0.4
Real Name: Georges

Re: Add Customer Name to Email Subject

Post by otrs-warrior »

thanks, it works like charm for getting the TicketID and CustomerID, but when it comes to the CustomerCompany section of the code, I wasn't able to fix it and the browser keeps giving me this error:
Software error:
Can't call method "CustomerCompanyGet" on an undefined value at /opt/otrs//Kernel/System/Ticket.pm line 791.
For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
which corresponds exactly to:

Code: Select all

    790     if ( $Param{CustomerID} ) {
    791     my %CustomerCompany = $Self->{CustomerCompanyObject}->CustomerCompanyGet( CustomerID => $Param{CustomerID}, );
    792     }
Some forum threads mention the need to add an event handler... any idea?
Best Regards
OTRS::ITSM 3.0.10 on Linux with MySQL database.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add Customer Name to Email Subject

Post by crythias »

You can't use $Self->CustomerCompanyObject because $Self is a TicketObject.
You'd need to create a new CustomerCompanyObject to get the info.

Check out dev.otrs.org for how to accomplish that. Basically,

Code: Select all

    my $CustomerCompanyObject = Kernel::System::CustomerCompany->new(
        ConfigObject => $Self->{ConfigObject},
        LogObject    => $Self->{LogObject},
        DBObject     => $Self->{DBObject},
        TimeObject   => $Self->{TimeObject},
        EncodeObject => $Self->{EncodeObject},
        MainObject   => $Self->{MainObject},
    );
Don't forget the use Kernel::System::CustomerCompany; at the top
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
otrs-warrior
Znuny newbie
Posts: 5
Joined: 13 Oct 2011, 19:28
Znuny Version: 3.0.4
Real Name: Georges

Re: Add Customer Name to Email Subject

Post by otrs-warrior »

Thanks a lot for your help :)
the following code did the trick within Ticket.pm / sub New { }

Code: Select all

$Self->{CustomerCompanyObject} = Kernel::System::CustomerCompany->new(%Param);
I'll be working next on using the ticket Title in all email Forward & Reply instead of using the Subject from the last email received. I hope it won't make much trouble :D
Cheers!
OTRS::ITSM 3.0.10 on Linux with MySQL database.
Locked