I am trying to write custom function in OTRS in which upon passing the parameters the function which I am writing should sort the tickets from different queues and write it to a file. These parameters maybe based on priority of the ticket etc etc. I just need to write this function and run in the OTRS. Can you please let me know how to achieve this task as this is my first time working with OTRS. What I know is that, in GenericAgent.pm I need to write a new sub which is like this
Code: Select all
_CustomTicket {
my ($Self, %Param) = @_;
# check needed stuff
for (qw(Name UserID)) {
if ( !$Param{$_} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $_!"
);
return;
}
}
return if !$DBObject->Prepare(
SQL => 'Select * from queue',
Bind => [ \$Param{Name} ],
);
my @Data;
open(my $fh,'>','bin/newpmfile.txt');
while ( my @Row = $DBObject->FetchrowArray() ) {
if($row1[3]=='2'){
print $fh "ticket: $row1[2] AAA QUEUE \n";
}elsif($row1[3]=='22'){
print $fh "ticket: $row1[2] BBB QUEUE \n";
}elsif($row1[3]=='3'){
print $fh "ticket: $row1[2] CCC QUEUE \n";
}elsif($row1[3]=='9'){
print $fh "ticket: $row1[2] DDD QUEUE \n";
}
}
close $fh;
},
If you can help me on this it would be great.
Thanks,