Javascript file generation problem

Hey all!

I have an app where it generates a file from modules per customer selected from a drop-down, which works, but now I want an option for a button to generate multiple files as well.

Working Javascript for one file:
The Javascript used for generating one file works with a for loop over a SQL query. The SQL query basically grabs the modules for the customer which are on and in an union which are off. The one thing you should note from this query is the customer_id is a drop-down, which is used to filter on the situation of that customer.

The Query:

The Javascript:

For multiple files:
I was working with the idea to expand the already working javascript file in another for loop above, that loops over all the customers itself, but that seems to bring me to a problem with the Query. The other query already filters out the situation for that customer, while with this one that is impossible.

I will gladly provide more information if things are unclear in this.
Thanks for any help in advance

Hi @FlorVk

Thanks for reaching out! I want to make sure I'm understanding the use case, so just to confirm -- Do you want to keep the same working process, but expand it to work for all customers at once instead of only 1 customer at a time? Are there any other constraints to be aware of? About how many customers are there in total? Would it loop through each customer and download one file for each customer?

Or, are you looking to download more than one file per customer?

My guess is that this doc may be helpful! But it would be great to hear more about your use case.