How to loop through all the keys in make.com

When I upload 3 files from the http://studio.softr.io, the make.com webhook will return “FIELD__MSRQYLUOL:0”, “FIELD__MSRQYLUOL:1” and “FIELD__MSRQYLUOL:2”, how can I loop through the key one by one in make.com, and extract all the files’ link?

the problem is I never know the exact key of name, the only thing I know is it will increase +1 everytime, if upload 5 files then the name will be FIELD__MSRQYLUOL:5

1 Like

Welcome to the Make community!

Unfortunately, if you do not know the number of fields that becomes trickier.

You can try using a Set Variable module to combine all the fields into a single array.

Those that aren’t present would be ignored. If not, you can use the remove function to remove null values.

e.g.:

{{ add(emptyarray; 2.FIELD_0; 2.FIELD_1;  2.FIELD_2;  2.FIELD_3; etc.) }}

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like

Hi @Alex15

You need to first use and array aggregator on this. Then use set variable and wrap the array output with toArray() function. Then iterate.

It will loop through all the keys.

Please download attached blueprint and adjust in your scenario.
blueprint (65).json (5.4 KB)

Regards,
Msquare Automation - Gold Partner of Make
@Msquare_Automation

As @samliew said, it becomes tricky when you don’t know the number of keys and the key names are subject to change too.

Another solution could be to use a text parser to extract the URLs from the object. This works if you know that the value always is a URL. You can enable JSON pass-through in the Webhook:

And then use a text-parser to retrieve the URL’s from the object. This will automatically split the result in bundles:

Result:

Cheers,
Henk

5 Likes

Thank you for your great suggestion. When I tried to rebuild your solution, however, it did not work. Therefore, I slightly adapted the implementation of the Text parser.

I used “Match pattern” (Regex) instead of “Match elements” with the following pattern:

https?:\/\/[^\s"]+

The output now gives me every URL nicely separated.