[SOLVED] include "mailto" in Notifications Event

Moderator: crythias

Locked
Giulio Soleni
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

[SOLVED] include "mailto" in Notifications Event

Post by Giulio Soleni »

Hi,
I would like to include a mailto link to allow agents to reply to tickets via email by clicking the link.
There is no problem with auto responses and with Agent Notifications which allow a html editing of the body of the message.
However I have also some Notifications (Event) that may be edited in plain text.
Indeed the mailto link is normally correctly interpreted but problem really exists when I use some OTRS tags in the mailto link that comprise blanks:

In the Agent Notifications I use the following (and it works):
<a href="mailto:help-test@iks.it?subject=[Ticket#<OTRS_TICKET_TicketNumber>] <OTRS_TICKET_Title> &body=%5Breply%5D">Reply</a>

In the Notifications (Event) I directly put the following:
mailto:"help-test@iks.it?subject=%27%5BTicket#<OTRS_TICKET_TicketNumber>%5D%20<OTRS_TICKET_Title>%27&body=%5Breply%5D"

but as soon as <OTRS_TICKET_Title> gets expanded in something like "subject with blanks inside" agents receive a notification with an incomplete link... something like:
mailto:"help-test@iks.it?subject=%27%5BTicket#2011041410000016%5D%20subject with blanks inside%20%5BAGT%5D%27&body=%5Breply%5D"

Where are OTRS tags expanded to compose the Notifications body?
It would be enough to substitute a "%20" with the simple blank to get the result.

Thank you
Last edited by Giulio Soleni on 04 May 2011, 12:09, edited 1 time in total.
OTRS 6.0.x on CentOS 7.x with MariaDB 10.2.x database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.
Giulio Soleni
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

[SOLVED] include "mailto" in Notifications Event

Post by Giulio Soleni »

I have solved my issue touching the /opt/otrs/Kernel/System/Ticket/Event/NotificationEvent.pm the following way:

Original ... around line #483

Code: Select all

    483     # ticket data
    484     my %Ticket = $Self->{TicketObject}->TicketGet( TicketID => $Param{TicketID} );
    485     for ( keys %Ticket ) {
    486         next if !defined $Ticket{$_};
    487         $Notification{Body}    =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
    488         $Notification{Subject} =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
    489     }
Modified (code comprised between # GSO EDIT START and # GSO EDIT END)

Code: Select all

    # ticket data
    my %Ticket = $Self->{TicketObject}->TicketGet( TicketID => $Param{TicketID} );
    for ( keys %Ticket ) {
        next if !defined $Ticket{$_};
    # GSO EDIT START
        if ($_ eq 'Title')
        {
          my $UnderscoredTitle = $Ticket{Title};
          $UnderscoredTitle =~ s/\s+/\%20/g;
          $Notification{Body} =~ s/<OTRS_TICKET_UTitle>/$UnderscoredTitle/gi;
          $Notification{Body} =~ s/<OTRS_TICKET_Title>/$Ticket{Title}/gi;
        }
    # GSO EDIT END
        $Notification{Body}    =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
        $Notification{Subject} =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
    }
Then, inside the notification body, whenever I want to use a string like "Ticket%20Title%20With%20Blanks" I will use <OTRS_TICKET_UTitle>.
When, instead, I would like to use a string like "Ticket Title With Blanks" I will use <OTRS_TICKET_Title>.
OTRS 6.0.x on CentOS 7.x with MariaDB 10.2.x database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.
Locked