Use id column from filtered table's visible rows as workflow parameter

  1. My goal: extract the id column of a table for the rows displayed with the current filter, not the whole list of ids in the table to submit to a workflow.
  2. Issue: Retool doesn't seem to expose the setting of what is currently filtered out and what is visible in a table. I see no property anywhere for that.
  3. Steps I've taken to troubleshoot: scoured the state of the table elements and underlying query, before and after changing table filter settings.
  4. Additional info: (Cloud or Self-hosted, Screenshots) I have a modal that pops up and asks for additional parameters before running the workflow, but I seem to need to requery the database for the exact same data leveraging the table's filterstack to get back only the relevant rows to pass to the workflow. Isn't there a way to get at the filtered table or the status of each row in that table?

Hi @rlhane.2_19635,

If you want to show the filtered data you can create filters by adding variables in your WHERE clause.

eg text input searchJobs. Type a job number or name.

then add:

WHERE
CAST(job_number AS text) ILIKE {{'%' + searchJobs.value + '%'}}
  )

Then when you filter using your text input you will see the data records change.

I hope this helps!

1 Like

Yes. I've already filtered the data with filters. Now I want to submit the id column of the filtered table (just the currently visible row ids) to a workflow as a parameter. I can get at the table's data and its filter stack. I either need to parse the filter stack and build an equivalent WHERE clause to draw out the pertinent ids with a Query JSON from SQL AlaSQL query, or, if possible, draw out the currently visible (unfiltered) rows from the table.

When you filter your table with the pre-existing filters, it will not show in the state. This, I beleive, is how you are setup. Is this correct?

My suggestion is to filter a different way, by using the query linked to the table and including where clauses there. If you share a few screenshots of your table, your input fields, and the query, I can guide you.

Here is a screenshot. Notice data has the 2 filtered items

2 Likes

Thanks Shawn. I'm fine. We were trying to draw the data once instead of hit the server every time a filter selection changes.

What I'm hearing from our dialog is that, no, Retool does not expose which rows are currently filtered out and which ones are currently visible (although the data is clearly there lurking underneath) , and they don't have a mechanism to use the filterStack of a table against a JSON query to get back only the unfiltered rows. I just needed to hear and accept that. I think I'll continue to apply search fields against the filterStack and when they hit the button to launch the workflow, requery the data with the search field values. It will be a bit tricky because one of the search fields accepts multiple tag values to intersect with a tag list column in the table, but I'll live.

Thanks, -Ron

Hey All,

Someone replied offline that there is a mytable.getDisplayedData() method that gives me what I'm after. I knew there has to be a simple solution. Too many smart people at Retool not to have one.

1 Like

Hi Ron,

Upon a little research there is a way!

const filteredRows = table1.getDisplayedData({ includeHiddenColumns: false })
  
return filteredRows;

Here is the link to the post.

2 Likes

Glad you found it Ron. Good luck with your project!

1 Like