EDIT: After some help from @sid I now have a much better solution than I originally had so I’ve deleted the original post to avoid confusion. The substantially better way to do this is…
I think you could have just used repeat for this. No need for temporary table.
In repeat step, you select the relevant keys/columns from the API response.
Inside repeat, after fetching the data from query, you can use multiple set value items for each relevant column and set output to true.
eg: Set value with name: tripbit value: query1[0].tripbit
Result would be like:
"repeat1":[
{
"public_id": "sdfsadf" ---------------------> from api, in repeat step,
"tripbit": "ddd", --------------------------> from query inside the repeat,
"bgcolor": "#eee", -------------------------> from query inside the repeat,
},
{
....
}
]
Also, you should use a single query instead of regular database query step. That way you can avoid using [0] index.
Quick additional question. Any idea how I would filter that data? I have a $_GET array category_group which holds a list of categories. I’d like to be able to filter the results of the repeat by that. I can put it into the single query, but there is still a record output for every item in the repeat.
That is correct. Repeat creates an entry for every iteration.
Best solution here would be from the API end. If you can filter the result via API request, your repeat would not require any changes.
If not, here's what I have done at one place where I had a similar requirement.
Inside the repeat, filter the single query. For unmatched category groups, you will see null entries in the report output.
Next, remove output from repeat. Just repeat. And create a separate set value step with output enabled, and set its value something like {{repeat1.where('tripbit_id', "!=", "null")}}. So the final output you will see from server action will be filtered.