[SOLVED] Problem after upgrade to 4.0.13

Moderator: crythias

Locked
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

[SOLVED] Problem after upgrade to 4.0.13

Post by Lubomirsb »

In the old version I was using a script which populated a dynamic field dropdown in AgentTicketPhone.dtl. (the event launches when queue is changed)
Its taken from here
After the upgrade there are not more .dtl files , they are now .tt. Ok I moved the script to AgentTicketPhone.tt.

Code: Select all

<script type="text/javascript">//<![CDATA[
$('#Dest').bind('change', function (Event) {

var MyVariable =  $('#CustomerID').val();
$.ajax({
  type:     'get' ,
  dataType: 'html' ,	
  url:   'extdata.pl'+'?q='+ MyVariable  ,
  success: function(html){
   
$("#DynamicField_Test2")
    .replaceWith('<select id="DynamicField_Test2" name="DynamicField_Test2" class="DynamicFieldText">' +
          html +
        '</select>');
     
  }
});
});
//]]></script>
This is below [% WRAPPER JSOnDocumentComplete %] .

I get error 500. I tried to see where the error is with :

Code: Select all

print '<option selected value="">-</option>';
1;
It seems to return error after :

Code: Select all

   $CommonObject{LogObject}    = Kernel::System::Log->new(
    LogPrefix => 'ExtData',
    %CommonObject,
   );
Any idea what i am doing wrong?
Last edited by Lubomirsb on 15 Oct 2015, 09:32, edited 1 time in total.
OTRS 3.3.4 ,Centos 6.5
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Problem after upgrade to 4.0.13

Post by Lubomirsb »

I solved the problem. The new extdata.pl

Code: Select all

#!/usr/bin/perl -w
use strict;
use warnings;

use CGI qw(:standard);
#use JSON; #install JSON via cpan/ppm if you want to use it instead

print header(-type => 'application/json; charset=utf-8');

#code to query data

# use ../../ as lib location
use FindBin qw($Bin);
use lib "$Bin/../..";
use lib "$Bin/../../Kernel/cpan-lib";
use lib "$Bin/../../Custom";


use Kernel::System::ObjectManager;


    local $Kernel::OM = Kernel::System::ObjectManager->new(
        'Kernel::System::DB' => {
            # if you don't supply the following parameters, the ones found in
            # Kernel/Config.pm are used instead:
            #DatabaseDSN  => 'DBI:odbc:database=123;host=localhost;',
            #DatabaseUser => 'user',
            #DatabasePw   => 'somepass',
            #Type         => 'mysql',
            Attribute => {
                LongTruncOk => 1,
                LongReadLen => 100*1024,
            },
            AutoConnectNo => 0, # 0|1 disable auto-connect to database in constructor
        },
    );

    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

	
   my $query = param('q') || '';
   my $like = '%' . $query . '%';
   my $ResultAsArrayRef = $DBObject ->Prepare(	
      SQL => "SELECT id, first_name FROM customer_user WHERE customer_id like ?",
      Bind => [ \$like ],
      Order => 'asc',
      Limit => 10
   );
#  my $json_text = to_json($ResultAsArrayRef);
#  print $json_text;
print '<option selected value="">-</option>';
while ( my @Row = $DBObject->FetchrowArray()) {


   print '<option value="' . $Row[1] . '">'. $Row[1] . "</option>\n";
   
   

}

1; 

Its working now but I need to access CustomerID from the customer interface in CustomerTicketMessage.tt . Any ideas how I can do that?
OTRS 3.3.4 ,Centos 6.5
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Problem after upgrade to 4.0.13

Post by Lubomirsb »

Solved that too. Need to edit in /Kernel/Modules/CustomerTicketMessage.pm -> _MaskNew . I added UserCustomerID as param.

Hope this thread will help someone :)
OTRS 3.3.4 ,Centos 6.5
Locked