Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

To work with autocomplete you need first to configure a datasource. If you did not, please refer to the How to configure datasource for SQL Custom Field

Configuring autocomplete Custom Field

...

To retrieve data, you will need first to connect to the database that stores your data for you. Choosing the right datasource will make the connection between the customfield and the database.

...

After choosing the datasource and the customfield custom field type (we assume that you choose picked autocomplete as customfield the custom field type). You will need now to fulfill the configuration with a working query. The query must first work and retrieve data on your DBMS.

To illustrate properly how it works we will try to , let's implement a real use case :

Suppose that we have the table  City in our database. Here is the structure of our database : 

...

Column Alias: When using an alias for the main column. If there is no alias then it the field must be the same as the column name.

Column name: The name of the main column

Loading data: Please choose select Automatique for autocomplete

Number of character characters to start the search: The number of taped characters to input before autocomplete startedstarts.

Number of the element to return: The number of elements to return as a result of the autocompletion.

...

Step 3: Retrieve more data

Childs Children fields will help you to retrieve more data into on issues. It's pretty simple to work with childs. You must know that there are no special customfield to create To work with Children fields, no special custom field is required, you can use JIRA customfield custom field as Text, Date, number, etc.

For our In the following example, the need query has been modified . So now, we need to select an id and, depending on this id we the plugin will retrieve the name of the city :

...

Query: The query must contain all the columns that you want to retrieve.

Column Alias: Explained by the use of  When using an alias for the main column: city_id as 'id'. If no alias is used,  then it must be the same as the column name.

And here is the result :











Complex configuration

Now that you are the usage of autocomplete is more familiar with using autocomplete to you, we can go one step further with the use of this a more complex configuration.

Suppose now that our database contains two the following tables as below:


Country
Country_id
Country

...

City
City_id
City
Country_id

So At this point, the need now is to retrieve the country for each selected city. Here's the new configuration :

...

Info
iconfalse

It's possible to join two or more tables. It's important to know that if the query works on your DBMS it will also work on the customfield custom field configuration except when :

  • Using ORDER BY, you must add in the where clause: column name like '%' in our example the query becomes:
Bloc de code
select city,country from city c inner join country co on c.country_id = co.country_id where city like '%' order by c.city_id



Here is the result for this of the custom field configuration :