Bind dynamic field Dropdown value with external data source
Moderator: crythias
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Bind dynamic field Dropdown value with external data source
Hi,
We are implementing OTRS and we have to implement a dropdown which is filled from external data source.
So the requirement is -
Whenever we select the customer in ViewPhoneTicketNew/ViewEmailTicketNew page.
The customer value will be send as a parameter to the query(external database), on the basis of this value, we fetched the values of dropdown.
So the issue is -
how to send the value of customer to query.
Where to write & call script.
How to bind the fetched values with dropdown.
Thanks in advance.
Regards,
GMunjal
We are implementing OTRS and we have to implement a dropdown which is filled from external data source.
So the requirement is -
Whenever we select the customer in ViewPhoneTicketNew/ViewEmailTicketNew page.
The customer value will be send as a parameter to the query(external database), on the basis of this value, we fetched the values of dropdown.
So the issue is -
how to send the value of customer to query.
Where to write & call script.
How to bind the fetched values with dropdown.
Thanks in advance.
Regards,
GMunjal
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
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
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
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
Thanks for the information.
We tried the steps marked in the link.
Now if we browse the EXTData.pl file, it shows us the drop down values. but still on GUI the drop down is blank.
In AgentTicketEmail.dtl, we use the below code :
<div class="Field">
<select id="myselect" name="DynamicField_TRP">
</select>
</div>
<script type="text/javascript">
$.get('http://localhost/otrs/extdata.pl', function(data) {
$('#myselect').append(data);
});
</script>
But still we didn't get the dropdown values.
Can inputs on above issue ?
Regards,
GMunjal
We tried the steps marked in the link.
Now if we browse the EXTData.pl file, it shows us the drop down values. but still on GUI the drop down is blank.
In AgentTicketEmail.dtl, we use the below code :
<div class="Field">
<select id="myselect" name="DynamicField_TRP">
</select>
</div>
<script type="text/javascript">
$.get('http://localhost/otrs/extdata.pl', function(data) {
$('#myselect').append(data);
});
</script>
But still we didn't get the dropdown values.
Can inputs on above issue ?
Regards,
GMunjal
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
Check your browser's javascript console. Make sure that jquery is on the page. Present here the extdata.pl result sample : 1 or 2 results
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
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
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
I use the below jquery
$.get('http://localhost/otrs/extdata.pl', function(data) {
$('#myselect').append(data);
});
but it didn't get called, as I check this by adding alert.
As if we open this URL directly, it gives us the below output :
<option value="abc"></option>
<option value="DEF"></option>
<option value="GHI"></option>
<option value="JKL"></option>
Any Imputs, is there is any wrong in JQuery ???
Regards,
GMunjal
$.get('http://localhost/otrs/extdata.pl', function(data) {
$('#myselect').append(data);
});
but it didn't get called, as I check this by adding alert.
As if we open this URL directly, it gives us the below output :
<option value="abc"></option>
<option value="DEF"></option>
<option value="GHI"></option>
<option value="JKL"></option>
Any Imputs, is there is any wrong in JQuery ???
Regards,
GMunjal
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
GMunjal wrote:but it didn't get called, as I check this by adding alert.
Nothing to show makes sense. You have no display value between <option ...> and </option>GMunjal wrote:<option value="abc"></option>
<option value="DEF"></option>
<option value="GHI"></option>
<option value="JKL"></option>
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
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
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
Hi,
Now Values are visible on extdata.pl, but data in dynamic field is still not visible. What should I do now?
Now Values are visible on extdata.pl, but data in dynamic field is still not visible. What should I do now?
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
Below are some more details of the issue :
If I open extdata.pl in browser as : http://1.1.2.20/otrs/extdata.pl
then it will show me a popup as : 'Do You want to open or save extData.Json from 1.1.2.20 ?' , If I click 'Yes' then is saves a file as extData.Json and when open the file it contains the below data :
So the first question is, Is the setup till now is correct ? or the values must be shown on browser instead of saving the file ?
Next is :
In AgentTicketPhone.dtl file I write the below JS code :
In the above code I used, if I click on dropdown , then it will show only the first alert as 'Show'.
So Is the above code need changes or do I require to write some other code to bind the data with dropdown having id 'DynamicField_TRP'.
I also tried to use the below code, but no luck :
Please provide your inputs on above...
If I open extdata.pl in browser as : http://1.1.2.20/otrs/extdata.pl
then it will show me a popup as : 'Do You want to open or save extData.Json from 1.1.2.20 ?' , If I click 'Yes' then is saves a file as extData.Json and when open the file it contains the below data :
Code: Select all
<option value="ABC-56">ABC-56</option>
<option value="ABC-57">ABC-57</option>
<option value="ABC-58">ABC-58</option>
<option value="ABC-59">ABC-59</option>
<option value="ABC-60">ABC-60</option>
<option value="ABC-61">ABC-61</option>
So the first question is, Is the setup till now is correct ? or the values must be shown on browser instead of saving the file ?
Next is :
In AgentTicketPhone.dtl file I write the below JS code :
Code: Select all
$('#DynamicField_TRP').bind('click', function (data) {
alert('show'),
$.ajax({
type: 'GET',
url: 'http://1.1.2.20 /otrs/extdata.pl',
data: data,
success: function(data){
alert('successful');
}
});
});
In the above code I used, if I click on dropdown , then it will show only the first alert as 'Show'.
So Is the above code need changes or do I require to write some other code to bind the data with dropdown having id 'DynamicField_TRP'.
I also tried to use the below code, but no luck :
Code: Select all
$.get('http://1.1.2.20/otrs/extdata.pl', function(data) {
$('#DynamicField_TimeRegistrationProject').append(data);
console.log(data);
});
Please provide your inputs on above...
Last edited by crythias on 17 Dec 2013, 14:55, edited 1 time in total.
Reason: [code] tags
Reason: [code] tags
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
There's a space in the URL...GMunjal wrote: url: 'http://1.1.2.20 /otrs/extdata.pl',
You should use the browsers' developer tools to debug AJAX calls like this.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
This is just a typo mistake in raising issue, else there is no space in code.
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
What does your Javascript console say?
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
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
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
You should copy'n'paste the code to this forum (and please use theGMunjal wrote:This is just a typo mistake in raising issue, else there is no space in code.
Code: Select all
tags) this would help us to help you...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
Why did you bind it on click?
If the following works, then your script should as well.
Make sure the select has an ID of DynamicField_TRP.
Don't forget that the dynamic field may not like values that aren't assigned, which means it might be better to use an input control instead of a select and use fuzzy search or change input field to a select field.
If the following works, then your script should as well.
Make sure the select has an ID of DynamicField_TRP.
Don't forget that the dynamic field may not like values that aren't assigned, which means it might be better to use an input control instead of a select and use fuzzy search or change input field to a select field.
Code: Select all
var data='<option value="ABC-56">ABC-56</option><option value="ABC-57">ABC-57</option><option value="ABC-58">ABC-58</option><option value="ABC-59">ABC-59</option><option value="ABC-60">ABC-60</option><option value="ABC-61">ABC-61</option>';
$('#DynamicField_TRP').append(data);
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
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
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
Thanks for the solution..
now on page load values get loaded in drop down using the below code :
$( "#DynamicField_TRP" ).load( "http://1.1.2.20/otrs/extdata.pl", function() {
alert( "Load was performed." );
});
, but new issue in the same arises... on page if I change the value of any other dropdown, the dropdown values of DynamicField_TRP get vanish/clears and doesn't load back.
Thanks,
now on page load values get loaded in drop down using the below code :
$( "#DynamicField_TRP" ).load( "http://1.1.2.20/otrs/extdata.pl", function() {
alert( "Load was performed." );
});
, but new issue in the same arises... on page if I change the value of any other dropdown, the dropdown values of DynamicField_TRP get vanish/clears and doesn't load back.
Thanks,
-
- Znuny newbie
- Posts: 83
- Joined: 15 Nov 2013, 15:19
- Znuny Version: 4.0.13
- Real Name: Lubomir
- Company: Expert-M
Re: Bind dynamic field Dropdown value with external data sou
Hope this helps.
In this case i replace the input with a dropdown (otherwise the value wont save in the database).
Look at that " url: 'extdata.pl'+'?q='+ MyVariable "
Code: Select all
$('#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>');
}
});
});
Look at that " url: 'extdata.pl'+'?q='+ MyVariable "
OTRS 3.3.4 ,Centos 6.5
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
Sorry for the confusion, as my issue is the dropdown value doesn't maintain if any ajax calls occurs on that page, i.e if any dropdown on the page change it values, my dropdown with external data source clears all its value and doesn't show again.
now on page load values get loaded in drop down using the below code :
$( "#DynamicField_TRP" ).load( "http://1.1.2.20/otrs/extdata.pl", function() {
alert( "Load was performed." );
});
, but new issue in the same arises... on page if I change the value of any other dropdown, the dropdown values of DynamicField_TRP get vanish/clears and doesn't load back.
now on page load values get loaded in drop down using the below code :
$( "#DynamicField_TRP" ).load( "http://1.1.2.20/otrs/extdata.pl", function() {
alert( "Load was performed." );
});
, but new issue in the same arises... on page if I change the value of any other dropdown, the dropdown values of DynamicField_TRP get vanish/clears and doesn't load back.
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
In the solution you provided, that will help me only if there is one dropdown on page..
but the issue is ---
There are 9 dropdowns on page and one submit button on page... when ever a AJAX call is placed(on any dropdown value changed or on button click), the dynamic dropdown I added( which is filled on after select the customerID) is got empty.
Ajax calls - This below is example of one ajax call shown on priroty ID value change.
$('#PriorityID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID',[ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
});
Please provide your input.
but the issue is ---
There are 9 dropdowns on page and one submit button on page... when ever a AJAX call is placed(on any dropdown value changed or on button click), the dynamic dropdown I added( which is filled on after select the customerID) is got empty.
Ajax calls - This below is example of one ajax call shown on priroty ID value change.
$('#PriorityID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID',[ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
});
Please provide your input.
-
- Znuny advanced
- Posts: 108
- Joined: 23 Oct 2013, 09:17
- Znuny Version: 3.3.0 beta 2
- Real Name: Gaurav Munjal
- Company: Nagarro
Re: Bind dynamic field Dropdown value with external data sou
In the solution you provided, that will help me only if there is one dropdown on page..
but the issue is ---
There are 9 dropdowns on page and one submit button on page... when ever a AJAX call is placed(on any dropdown value changed or on button click), the dynamic dropdown I added( which is filled on after select the customerID) is got empty.
Ajax calls - This below is example of one ajax call shown on priroty ID value change.
$('#PriorityID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID',[ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
});
Please provide your input.
but the issue is ---
There are 9 dropdowns on page and one submit button on page... when ever a AJAX call is placed(on any dropdown value changed or on button click), the dynamic dropdown I added( which is filled on after select the customerID) is got empty.
Ajax calls - This below is example of one ajax call shown on priroty ID value change.
$('#PriorityID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID',[ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
});
Please provide your input.
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Bind dynamic field Dropdown value with external data sou
$Data{"DynamicFieldNamesStrg"}
Wherever this is says update the DynamicField(s) on the page.
Wherever this is says update the DynamicField(s) on the page.
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
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
Re: Bind dynamic field Dropdown value with external data sou
So I faced the same problem with the dynamic drop down being emptied whenever I changed the value of another dropdown on the same page.
This is a possible solution. It seems to work for me but is not fully tested.
Edit this file:
and go to line 258 where it reads:
and change it to read:
It seems that the FormUpdate function being called clears the dropdown values and re-loads the data as per OTRS dynamic fields. Of course in OTRS it is an empty dropdown.
Since Value[1] is used later to repopulate the dropdown around line 269
it seems that Value[1] is either saved earlier or taken directly from OTRS dynamic field values. So adding a simple check Value[1] is not empty serves to avoid emptying the drop down.
Hope this helps.
This is a possible solution. It seems to work for me but is not fully tested.
Edit this file:
Code: Select all
/opt/otrsvar/httpd/htdocs/js/Core.AJAX.js
Code: Select all
if ($Element.is('select')) {
$Element.empty();
Code: Select all
if ($Element.is('select')) {
if (Value[1])
$Element.empty();
Since Value[1] is used later to repopulate the dropdown around line 269
Code: Select all
NewOption.innerHTML = Value[1];
$Element.append(NewOption);
Hope this helps.
OTRS v3.3 private testing on Fedora 18 with Apache and MySQL
-
- Znuny newbie
- Posts: 26
- Joined: 10 Jul 2014, 19:58
- Znuny Version: 4.0.3
- Real Name: Jorge Rojas
- Company: Instituto Costarricense de Electricidad
- Location: Costa Rica
Re: Bind dynamic field Dropdown value with external data source
I know this thread is old but I need to know which is the best way to resolve the problem of dependent fields (I have 3: State, City, Street). For all of the people has posted I see 2 options: 1. replace Data{"DynamicFieldNamesStrg"} with explicit dynamic fields names and 2. modify Core.AJAX.js. I'll thank appreciate if someone give me a light to resolve this issue in easier way or know a new one.