Dependencies on the user input
In Jira, it's best practice to limit the number of options available in select lists for custom fields. This practice addresses two primary concerns:
Usability: Too many options can make the field hard to use.
Performance: A large number of options can cause performance issues.
Elements Connect custom fields and connected items can display up to 1000 items. Therefore, dynamically updating the options available as the user types is crucial for handling large datasets effectively.
The $userInput
variable can be used to filter the results dynamically based on what the user is typing, addressing both usability and performance concerns.
The examples below illustrate how $userInput
can be implemented in SQL queries and REST API requests.
Example: Customers
Consider a custom field for "Customer" with many different company names sourced from a CRM. There can be thousands of company names, making it cumbersome to search through all options. To address this, you can configure the field to filter options based on user input.
For example, if you start typing "Acme" for "Acme Corporation", the field will only search for company names in the data source that contain "Acme".
SQL example configuration:
SELECT name FROM customers WHERE company_name ILIKE '%' || '$userInput' || '%'
When the user types "Acme", the executed SQL query will be:
SELECT name FROM customers WHERE company_name ILIKE '%' || 'Acme' || '%'
This query ensures that as the user types, the options are filtered to match the input dynamically. This approach is particularly useful for very large datasets that cannot be fully queried at once.
REST API example configuration:
GET /api/customers?name=$userInput*
When the user types "Acme", the executed REST API request will be:
GET /api/customers?name=Acme*
An additional advantage of using $userInput
in a REST API context is that most APIs return a limited number of options (e.g., 100). Filtering the results with $userInput
is the only way to access specific values within large datasets efficiently.
Conclusion
By dynamically filtering options based on user input, you can enhance both usability and performance in Jira custom fields. Whether using SQL queries or REST APIs, this approach ensures that only relevant options are presented to the user, improving the overall experience.