[SOLVED] HELP: External Data Get drop down list options

Moderator: crythias

Locked
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

[SOLVED] HELP: External Data Get drop down list options

Post by damirun »

Thi is not a new topic, but, I need help to use an external data source to fill dynamic field drop down or a simple text file. I have replied to this old topic viewtopic.php?f=60&t=17033 but I haven't got any response.

Please, can anyone help me?

This is what I have done till now:
- created the extdata.pl and put it in /otrs/bin/cgi-bin folder
- creted dynamic drop down field XXX
- added the code for a sample select into AgentTicketZoom.dtl with the fieldname "name="DynamicField_XXX"" and at the bottom the javascript code

I have the dropdownlist but is empty!

Can anynone help me with this?

I'll appreciate any help...thanks.
Last edited by damirun on 11 Nov 2014, 16:37, edited 1 time in total.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: HELP: External Data Get drop down list options

Post by crythias »

What did you do? What's the view-source result of the list? what is the search criteria? Is the URL returning anything of value if you hit it directly? How can we replicate your experience? What are you trying to fill? Are there javascript errors? Is the data source working?
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
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: HELP: External Data Get drop down list options

Post by RStraub »

You might want to take a look at this package:
viewtopic.php?f=64&t=24499
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

Re: HELP: External Data Get drop down list options

Post by damirun »

crythias wrote:What did you do? What's the view-source result of the list? what is the search criteria? Is the URL returning anything of value if you hit it directly? How can we replicate your experience? What are you trying to fill? Are there javascript errors? Is the data source working?
Hello crythias and thanks for your replay. I'll try to explain what did I do...

I'm trying to get values into dynamic drop down field "DDL" that I have created. The values are the result of the select that resides in extdata.pl (for now just a simple select for testing):
********************************************************************
my $ResultAsArrayRef = $CommonObject{DBObject}->Prepare(
SQL => "SELECT id, login FROM users",
Order => 'asc',
Limit => 10
);
********************************************************************

If I browse the url http://localhost/otrs/extdata.pl ....I get the list of users correctly.
********************************************************************
<option value="1">Admin</option>
<option value="10">agente1</option>
<option value="12">agente11</option>
....and so on.
********************************************************************

If I go to the page http://localhost/otrs/index.pl?Action=A ... cketID=436 ....I don't have any value into the dropdownlist. The code that I use into the AgentTicketZoom.dtl is:
********************************************************************
<select id="myselect" name="DynamicField_DDL">
</select>

********************************************************************

...and at the bottom:
********************************************************************
<script type="text/javascript">
$.get('extdata.pl', function(data) {
$('#myselect').append(data);
});
</script>
********************************************************************

In the log file I don't see any error.

Do you have any suggestion for me... can I try to do some other test... ?

Thanks.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: HELP: External Data Get drop down list options

Post by crythias »

also make sure jquery is loaded.
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
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

Re: HELP: External Data Get drop down list options

Post by damirun »

crythias wrote:also make sure jquery is loaded.
I have searched the forum messages and founded something about the "lightbox plugin". I have downloaded the package and put it under the path: \otrs\OTRS\var\httpd\htdocs\js\thirdparty\lightbox... and then added the following scritps into the HTMLHead.dtl:
***********************************
<script src ="$Config{"Frontend::WebPath"}js/thirdparty/lightbox/js/jquery-1.11.0.min.js"></script>
<script src ="$Config{"Frontend::WebPath"}js/thirdparty/lightbox/js/lightbox.js"></script>
<link href="$Config{"Frontend::WebPath"}js/thirdparty/lightbox/css/lightbox.css" rel="stylesheet" />
***********************************
...but no data is loaded into my "DynamicField_DDL".

Am I done something wrong or I have to do something else?

Thanks again crythias.
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

Re: HELP: External Data Get drop down list options

Post by damirun »

RStraub wrote:You might want to take a look at this package:
viewtopic.php?f=64&t=24499
RStraub thanks for that add-on, but I have to ask you something more. I hope you'll answer me because I can't find out why I don't see my dropdownfield DDL.

I have installed the package "DynamicFieldRemoteDB". Created a RemoteDB field DDL. Added the field into Frontend::Agent::Ticket::ViewZoom system configuration... but when I'm on the ticket page "http://localhost/otrs/index.pl?Action=A ... etID=420"I don't see anything!

My DatabaseDSN is: DBI:SQL Server:Database=DBNAME;Server=localhost;

What could be wrong?

I appreciate any help...thanks!
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: HELP: External Data Get drop down list options

Post by crythias »

$.get('extdata.pl'

use fqdn/full path.
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
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

Re: HELP: External Data Get drop down list options

Post by damirun »

crythias wrote:$.get('extdata.pl'

use fqdn/full path.
I've put the following path:

$.get('otrs/bin/cgi-bin/extdata.pl', ... or ... $.get('/otrs/bin/cgi-bin/extdata.pl', ...

but I think it's not correct because the dorpdown list is still empty.

Can you give me another suggestion?

Thanks a lot!
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: HELP: External Data Get drop down list options

Post by crythias »

javascript renders client side, not server side.

http://server/path/file.ext
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
damirun
Znuny newbie
Posts: 9
Joined: 24 Oct 2014, 12:56
Znuny Version: 3.3.3
Location: Italy

[SOLVED] - HELP: External Data Get drop down list options

Post by damirun »

crythias wrote:javascript renders client side, not server side.

http://server/path/file.ext
Thanks crythias for your help but I can't figure out where I'm wrong. Anyway, I've had searched more the forums and found a solution at my problem. I substituted this code:

********************************************************************
<script type="text/javascript">
$.get('extdata.pl', function(data) {
$('#myselect').append(data);
});
</script>
********************************************************************

with this one:

********************************************************************
<script type="text/javascript">
var request = $.ajax({
type: 'GET',
url: 'extdata.pl?q=' + txt,
dataType: 'html'
});

request.done( function(data){
$('#myselect').empty();
$('#myselect').append(data);
});
********************************************************************

and now all is fine.

Thank you again for the time spent with my problem.
Locked