Hi Team,
I am new to retool and trying to prepare a workflow, below is the goal:
Receive a json array over Webhook URL.
Loop data and run workflow for each row/object.
Immediately after the loop there is a if conditions based on tenant (there are 3 different tenant).
Each tenant have 4 different API need to be triggered for each row.
I have tested the flow and it is working perfectly fine if I received single json object and without loop, but when receiving an array it is not working, in fact I am not getting the edia how to do that.
Attached is the screenshot of my initial flow for the reference. Any help or suggestion will be highly appreciated.
The main questions is how to pass each earch row of data one by one to "branch1" and map tenant from each row to check the tenant so that the respected flow for the tenant can be triggered.
Thank you in advance.
The issue you have here is you are always only checking on the first result in the array in your branch.
I think what you want to do is use a Filter block instead of the branch (to keep with your current design). For this your Branch node will become three Filter nodes, each attached to the preceding loop.
In the setup for each, you will set the array input to be the loop and then in the filter conditions, you will be filtering on the tenant property of the value:
Hello @pyrrho !
Thank you for the quick update!
I have tried that as well but the problem arrise when I map the value of username with the API for each tenant and further more API calls.
Attached is the screenshot to give you response what I have tried. Can you please suggest how to map the value of username to each API for the respected tenant ? The API will except only 1 username for each run.
Please suggest me what I am missing and how to map username with each API and run the iteration ?
BTW, I expect hundreds of records over webhook and multiple rows for each tenant and there can be scenario where not even a single row for a specific tenant.
What I would do is actually a little different than the design I am suggesting, but I will tackle the immediate question first and then pose an alternate thought.
Since your query calls at the end are handled one at a time you will need another loop to call all of the elements in the filtered array. I'm not sure of the setup for a looped Imported Resource Query but I am confident that you can create a new function to use this call and then use JS to trigger the function for each element in the loop.
The functions are defined on the sidebar (the little italicized f) and are called in JS like so: yourFunction(param1,param2) -- this is a little different than most queries which use the trigger() function and additionalScope options.
The function has input parameters for you to setup (and a test value area) which you then use in the function body as {{yourParam}}. When getting the return data from the function, you will need to await the responses so you can gather the results so the call in JS would look something like: var respone = await yourFunction(param)
My alternate thought is that if you are going to trigger your Imported Query (as a function) in a looping JS node, you can consolidate the filter step into this code, triggering the function with the proper parameters for each tenant.
This will not only help keep the workflow simple but also allow you to better handle errors and maintain better code readability and usability.