Retool Workflows

Hi Retoolers,

I have just started using Retool Workflows and have successfully deployed my first workflow on a scheduled trigger. I have an app where I want to reference the result of the workflow in a table.

Flow:
Everyday the query runs at 3pm
Users should be able to check the app daily after 3pm to see refreshed data.

I tried using the resource Retool Workflow and selecting the workflow but I got no results.

How can I reference that result set in my table in my app itself?

Hey @AccoladeRetool -- if I understand correctly, the workflow is responsible for populating the table you need to show to users.

If that is the case, then you should be able to just use a table in your App and make the data source the response of a query that gets all of the refreshed data from where the workflow populated it.

Overall, you'd have:
3pm: Workflow run populates/modifies yourBackendTable
User: Opens app and latest data is displayed using a query that selects all from yourBackendTable

HI @pyrrho thanks for your prompt response. The workflow is just querying an existing database table, but its not populating data to another table, just refreshing an existing table, is there a way to just reference the query the workflow is running in app? Maybe my understanding of how workflows may be misguided as well.

I would suggest just running the query in your app then and not having a workflow at all.

You can setup the query in the app to run automatically when the page loads and then use that as the data source for the table. There should be a built in refresh button on the OOTB table to refresh the query and regenerate the table data.

ETA: I will say that you can use a workflow in your app to accomplish this as well (for the future). In this case, you could setup a connection to the workflow in the App and then in the workflow use a response node to send data back to the App which you would use as your table data.

Thanks for your help @pyrrho do you have an example of doing what you described in your ETA section? I am just still wrapping my head around how this all works.

Absolutely!

I just slightly modified the "new Workflow" default code to enable a webhook and provide the response in the form of the example code block:

In an app, you would then create a workflow import query and set the behavior to run automatically:

And then here's the query response being used as the table data:

image

1 Like

Hi @pyrrho thanks for those steps,, really appreciate it. I went ahead and tried those steps but got no results but I feel like something may be missing on my end.
Screenshot of the Workflow:


Screenshot of the app:

I didn't see an option for run behavior in my resource as well.
It also looks like I get an error saying Referenced block is not connected. It doesn't seem to want to connect when i try to connect them, I just get a red X on the connection line.
image

A couple of things:

  1. That block needs to be connected -- I'm not sure what the red X you are describing is (unless it is the X that shows up on the line when you hover over it to break the connection). Can you show a screen shot of what it looks like when you get the red X?

  2. The run behavior option seems to be hidden behind your "Output" drawer. To the right of the tab that says Output is a double down chevron that you can click to collapse the Output.

ok so it looks like it is running now and I can get results in my app so I am not sure what happened but the x is still there, but when I run it I see the log shows success(which I wasnt getting before)
image

1 Like

That X looks like the one that deletes the line. Maybe just refreshing the page will clear it up.

In any case, glad the workflow -> app response is working for you!

I think we are good now. Thanks for all the help!

2 Likes

Hi @pyrrho I had a follow up question, let me know if it needs to be a separate post.

Is it possible to reference a variable in another app in the coding block? For example, end user goes to app, wants to have Retool check every hour for a file arrival for which they input the file name into the app then be notified once workflow query finds the final name has arrived.

Is that possible?

I think you could build a cache/service bus type of DB table (A Retool DB would probably be sufficient) to hold the user/filename requests and then your workflow would be running every hour checking it's connections for those files and taking actions when they are found (filter/conditional blocks). When the workflow finds the file and triggers the notification/alert/your mechanism of action it would also remove the user/filename request from the queue.

I have an app which accepts user requests and then kicks off a related set of external process steps which must be run in series. User requests are written into a Retool DB and trigger the workflow to start the external process. When the process is complete it sends a webhook trigger back to my workflow which removes the top queued item and checks for another item until the queue is empty.

Thanks @pyrrho very helpful

might wanna be a little careful here with how many times you call that workflow. the free plan gets 500 workflow runs per month and a single run is counted anytime your workflow is triggered and successfully executes (the docs don't say specifically what this means, but at a min it means no errors... it could also mean only when 2xx status code is returned). currently, 1 user can take up 24 of these a day and in a worse case scenario you run out of runs in 20ish days. if you're able to I'd suggest making a duplicate of the workflow but only in resource queries in your app. each block would probably become its own query and you can connect them (like the lines between blocks in workflows) using the onSuccess/Failure events or automatic run behavior w watched inputs set