Issue in Dynamic field using external data sources

Moderator: crythias

Locked
GMunjal
Znuny advanced
Posts: 108
Joined: 23 Oct 2013, 09:17
Znuny Version: 3.3.0 beta 2
Real Name: Gaurav Munjal
Company: Nagarro

Issue in Dynamic field using external data sources

Post by GMunjal »

Hi ,

We are using otrs , and below is the description :
Task : To add a Dropdown dynamic field whose data is filled using external data-source.
What works well : We create extdata.pl in bin folder, when we explore this file in browser , it gives us the expected output.
How we implement this : We use viewtopic.php?f=60&t=17033 link to implement the list type drop down. As in the same post, as shown below is mention

Code: Select all

Also, it *might* be likely that a DynamicField_XXX configured as a dropdown/Select might be problematic if you provide values that aren't in the list. 
An option to workaround this is to use a Dynamic Field that's a text input and change an input to a select or to use autocomplete/fuzzy search.
So we use input text type dynamic field, when we fill the values (we fill values on changing of customerID text field) we replace the input text with select type as shown below :

Code: Select all

$("#FromCustomer").on("focusout",setInterval(function(Event) 
{

	if ($("#CustomerID").val() != lastValue) 
	{	
		
       	lastValue = $("#CustomerID").val();		
		$.ajax({
  				type:     'get' ,
  				dataType: 'html' ,   
  				url:   'http://1.1.2.2/otrs/extdata.pl' +'?q=' + lastValue ,
  				success: function(html)
				{	
					$('.Row_DynamicField_TRP').show();
   					$("#DynamicField_TRP")
    					.replaceWith('<select id="DynamicField_TRP" name="DynamicField_TRP" >' +
          				html +
        				'</select>');   
  				}
			});
}
So below is the issue we faced : When a value is changed in customerID, the function calls well, values filled in list type and dropdown is shown instead of textbox for a while, but when the Ajax call ends and the loading circle stops loading data in other dropdown, the dynamics field again converts to text field in the editable format.

So how can we maintain the dropdown and there values to be maintain.

Any idea on this will helpful to us. Let us know if any more inputs to describe issue required.

Thanking you in advance.
Locked