https://manual.limesurvey.org/SGQA_identifierhttps://yourdomain/survey/index.php/SurveyIdNumber/lang-en?SurveyIdNumberXxXx=<OTRS_TICKET_TicketNumber>
Disclaimer: this is not related to OTRS. It's an idea. ignore it.
"I really would like to have different surveys for each queue ..."
Take a look at LimeSurvey as an option and create a Response for the Queue with a link to the survey you want.
"But how do I link the survey to my ticket/user?"
one way to do this is by back-door using the ticket number as a token in limesurvey.
"Huh?"
A given survey has a survey id (sid=68292, for instance)
if you make the survey a closed survey, there will be a token table created, for example:
lime_tokens_68292
there are several fields here: firstname,lastname,email,sent,usesleft,validfrom, validuntil
all of which may be of importance (you may, for instance, want to expire a survey a few days out)
The most important thing you'll need to insert is "token". That should be the value = the ticket id.
The survey link would then be, for examplehttp://serverHostingLimeSurvey/limesurv ... 1110000012
That link should be pretty easy to generate in a Response
"OK, so ... how do I get a ticketnumber into the table?"
one way is to create an event:
You need an XML file in Kernel/Config/Files:
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="Ticket::EventModulePost###LimeSurvey" Required="0" Valid="1">
<Description Lang="en">Enable for token generation for LimeSurvey</Description>
<Description Lang="de"></Description>
<Group>Ticket</Group>
<SubGroup>Core::Ticket</SubGroup>
<Setting>
<Hash>
<Item Key="Module">Kernel::System::Ticket::Event::LimeToken</Item>
<Item Key="Event">(TicketCreate|TicketQueueUpdate)</Item>
</Hash>
</Setting>
</ConfigItem>
</otrs_config>
maybe something like this to drop in Kernel/System/Ticket/Event/LimeToken.pm
Code: Select all
package Kernel::System::Ticket::Event::LimeToken;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.12 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for (qw(ConfigObject TicketObject LogObject UserObject CustomerUserObject
SendmailObject EncodeObject MainObject)) {
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
# create Lime DB Object
$Self->{LimeObject} = Kernel::System::DB->new(
ConfigObject => $Self->{ConfigObject},
EncodeObject => $Self->{EncodeObject},
LogObject => $Self->{LogObject},
MainObject => $Self->{MainObject},
DatabaseDSN => 'DBI:mysql:database=limesurvey;host=localhost;',
DatabaseUser => 'limesurvey',
DatabasePw => 'limedbpassword',
Type => 'mysql',
);
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Data Event Config)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_
!" );
return;
}
}
for (qw(TicketID)) {
if ( !$Param{Data}->{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_ in Data!" );
return;
}
}
if ( $Param{Event} eq 'TicketCreate' ) {
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
DynamicFields => 0,
);
if ( $Ticket{Queue} eq 'Main' ) {
$Self->{LimeObject}->Do(
SQL => "INSERT INTO lime_tokens_68292 (token) VALUES (?)",
Bind => [ \$Ticket{TicketNumber} ],
);
# do some stuff
$Self->{TicketObject}->HistoryAdd(
TicketID => $Param{Data}->{TicketID},
CreateUserID => $Param{UserID},
HistoryType => 'Misc',
Name => 'Updated Token!',
);
}
}
elsif ( $Param{Event} eq 'TicketQueueUpdate' ) {
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
DynamicFields => 0,
);
if ( $Ticket{Queue} eq 'Junk' ) {
# do some stuff
$Self->{LimeObject}->Do(
SQL => 'INSERT INTO lime_tokens_68292 (token) VALUES (?)',
Bind => [ \$Ticket{TicketNumber} ],
);
$Self->{TicketObject}->HistoryAdd(
TicketID => $Param{Data}->{TicketID},
CreateUserID => $Param{UserID},
HistoryType => 'Misc',
Name => 'Added a token for the survey'
);
}
}
return 1;
}
1;
In summary, this makes a one-shot survey available.
"But you promised multiple surveys!!!"
Well, yeah, if you pay attention, you can add a bunch of "ifs" in this event and update the appropriate "tokens" table for that Queue.
Then, if you create a Response associated with that queue, you'll have a link that connects to the appropriate survey id for the queue, which you'd additionally hard code in your event.
This example has a LOT of importance to programming against OTRS.
You have:
- Connection to an external database
- A real example of an event
- An example of passing a ticket number as a key value to another database