Mapping array collections to variables

Dear all,
I have this array that I want to create variables for each task_type. I only opened one of them, as it will be otherwise too long.

I tried using array —> iterator —> variable counter —> set variable

but it just seems to override itself after looping through…

Any advice how to set variableS?

I do not know if there will be 8 or 14 or 18 bundles each time, so it’s not possible to set the variables manually.


all,

You can use the built-in function toCollection

e.g.:

{{ toCollection(1.array; "task_type"; "task_content") }}

For more information, see https://www.make.com/en/help/functions/array-functions.html#tocollection--array--key--value-

2 Likes

Hi sam,

I tried this, but it returns an error… :frowning: what am I doing wrong here? thank you in advance fro your help.



If you need further assistance, please provide the following:

1. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

2. And most importantly, Input/Output bundles

Please provide the input and output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

Dear Sam,
Kindly check the output bundle that I am having difficulties mapping to a text aggergator for further onwards processing.

==================

[
{
“array”: [
{
“task_type”: “crosscheck_title_output”,
“task_content”: “YES”
},
{
“task_type”: “faq”,
“task_content”: “### What does lemon juice do to a potato?\n@@@ Lemon juice prevents potatoes from discoloring by slowing down the oxidation process. When you soak cut potatoes in water with lemon juice, the citric acid from the lemon helps maintain their natural color.\n\n### What potatoes does Gordon Ramsay use?\n@@@ Gordon Ramsay often opts for Yukon Gold Potatoes in his recipes. They have a good balance of starch and moisture, making them versatile for various cooking methods, including roasting and mashing.\n\n### Should I marinate potatoes?\n@@@ Yes, marinating potatoes can significantly enhance their flavor. A brine or marinade allows the seasonings to penetrate the flesh of the potatoes, resulting in a more flavorful dish.\n\n### What potatoes are best for roasting?\n@@@ For roasting, Russet Potatoes are excellent as they get crispy on the outside and fluffy inside. Yukon Gold Potatoes are also good for roasting, offering creamier centers and a richer flavor.\n\n### Can I use dried lemon zest instead of fresh lemon juice for Greek-Style Lemon Potatoes?\n@@@ Yes, you can use dried lemon zest as a substitute. It will give a different but still citrusy flavor. However, you might miss the tangy moisture that fresh lemon juice provides.\n\n### How long can I store leftover Greek-Style Lemon Potatoes?\n@@@ Leftover Greek-Style Lemon Potatoes can be stored in the refrigerator for up to 3-4 days. Make sure they’re in an airtight container to maintain freshness.\n\n### Is it necessary to peel the potatoes for this recipe?\n@@@ Peeling is not necessary, especially if you’re using thin-skinned potatoes like Yukon Golds. Keeping the skin on can add texture and nutrients. However, for a more traditional texture, you might prefer to peel them.”
},
{
“task_type”: “ingredients_exp”,
“task_content”: “- @#@Potatoes#@#: Foundation of the dish, their starchy goodness absorbs the flavors, creating a comforting, hearty base.\n\n- @#@Garlic#@#: Adds a pungent kick, essential for depth and a slight heat, which complements the zesty lemon beautifully.\n\n- @#@Olive Oil#@#: Provides richness, helps crisp up the potatoes, and carries the oregano and lemon flavors throughout the dish.\n\n- @#@Chicken or Vegetable Broth#@#: Adds moisture and a savory note, ensuring the potatoes don’t dry out while baking.\n\n- @#@Lemon Juice#@#: Brings a bright, acidic contrast to the earthy potatoes, giving the dish its signature Greek zing.\n\n- @#@Dried Oregano#@#: Offers a hint of Mediterranean herbaceousness, which is classic in Greek cuisine and pairs well with lemon.”
}
],
IMTAGGLENGTH”: 3
}
]