Our application includes a feature for admin users to create their own criteria for generating reports. The user can select a column name and then enter values to include/exclude records where the values match for that column in the database table. When reports are generated (via a separate backend service), the reporting application will use these filter
records to know which database rows to include in the report(s).
When creating a new reporting filter, the user selects a database column name (Attribute name
on the data entry page) from a pre-populated dropdown. The user must then enter desired values into a text array input field. Unfortunately, this approach requires the user to know exact text values that could include abbreviations, hyphenations, punctuation, odd spellings, etc. This can result in user error when the value isn’t entered exactly as it exists in the database table column.
Our users have requested that the Values
text array be a dropdown that contains only the distinct values for the selected column name. (See the screenshot below.)
I see from this documentation, that I can create a dynamic list of values for a dropdown: Custom dynamic dropdown in a form using smart collections - Developer guide
I can easily follow those instructions to make the Values
dropdown list dynamic. This would include creating a new route that looks something like this:
router.get('/filterValues/:columnName',...
I could then inject columnName
into a custom SQL query to retrieve all distinct values for that column. For example:
const query = `SELECT DISTINCT ${columnName} FROM my_table;`
But the issue is that I will need to know the current on-screen, user-entered value in the Attribute name
field in order to construct the GET request for the dynamic type, smart value dropdown. Is there any way to accomplish this? In other words, can I use current value of an on-screen field within the URL definition for the dynamic/smart dropdown?
Thanks!