How to use dynamic query on a database custom field in an issue
The following steps will guide you on how to use a dynamic query to retrieve values for a database custom field, based on the values of other custom fields :
- Check in the administration page that you have a dynamic sql configured
The database custom field Product Name depends on the custom fields Published(customfield_10410) and Not published(customfield_10411).
- Go to the issue and try to edit it. For this example, it is used the same issue as in the Autocomplete page. So it looks like in the following picture on edit:
- Let's change the values for the fields Published and Not published, special created for this example. These fields have the ids: customfield_10410(Published) and customfield_10411(Not published). These are simple JIRA custom fields, of type "Text Field (< 255 characters)".
- Let's type in first "jjupin" for Published. When leaving Published input textbox, the values for Product Name and Product Id fields are dynamically changed to empty values, and the available list of values for Product Name is updated(this will be visible when trying to enter a new value by using autocomplete) depending on the values of the fields Published and Not published.
- In the mean time we can type in a value for Not published as well(databasecf)
- Let's now use the autocomplete to see the values available for the main database custom field Product Name:
The only option left is the one displayed, which is equal with the value of Published.
On selection, the child database custom field is automatically filled in with the id of the selected product.
Every database custom field has a default value: blank, displayed in a the field of type Select List as "None".
- After saving the issue, the values for the custom fields are displayed in the view issue screen:
In a similar way, the dynamic query is used to retrieve values for a database custom field in a select list.
For the next example where the parent fields depend on each other, when one field changes, all of the dependent fields are changed:
Which means in the following screen that:
- Product Name depends on Category and has Product Code,
- Version depends on Product Name and has Release Date.
Changing Category field from support to services, all the values are changed.
Note that if session expires, the autocomplete, or other requests will not be completed, but JIRA can update the issue if the password of the user is kept in memory.