Obtaining non-empty elements from "array of multiple collections"

I received an output from HTTP module in nested form. I ran an iterator with aggregator to map a variable i.e. related searches. Now I want non empty values of Related searches from the available array of collections. kindly refer to the image below.

here, there are 7 collections in which there are 2 non empty arrays. I want elements in these two non empty arrays merged into one array.

Welcome to the Make community!

Please provide the 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.

This will allow others to better assist you. Thanks!

2 Likes

Array Aggregator

InputBundle

[
    {
        "related search": null
    },
    {
        "related search": null
    },
    {
        "related search": [
            null,
            null,
            null
        ]
    },
    {
        "related search": [
            null,
            null,
            null
        ]
    },
    {
        "related search": [
                    "concentration",
                    "improve memory",
                    "memory power",
                    "naturally",
                    "improved",
                    "short-term memory"
        ]
    },
    {
        "related search": [
            null,
            null,
            null,
            null
        ]
    },
    {
        "related search": [
                    "memory",
                    "Foods",
                    "memory recall",
                    "improve memory",
                    "students",
                    "long-term memory"
        ]
    }
]

Output Bundle

[
    {
        "array": [
            {
                "related search": null
            },
            {
                "related search": null
            },
            {
                "related search": [
                    null,
                    null,
                    null
                ]
            },
            {
                "related search": [
                    null,
                    null,
                    null
                ]
            },
            {
                "related search": [
                    "concentration",
                    "improve memory",
                    "memory power",
                    "naturally",
                    "improved",
                    "short-term memory"
                ]
            },
            {
                "related search": [
                    null,
                    null,
                    null,
                    null
                ]
            },
            {
                "related search": [
                    "memory",
                    "Foods",
                    "memory recall",
                    "improve memory",
                    "students",
                    "long-term memory"
                ]
            }
        ],
        "__IMTAGGLENGTH__": 7
    }
]

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of two modules:

Output:

Screenshot_2024-04-16_220445

Give it a go and let us know if you have any issues!

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.

  3. Click on each imported module and save it. You may need to remap some variables.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 120,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "other",
                        "otherRowSeparator": "|",
                        "feeder": 119
                    },
                    "mapper": {
                        "value": "{{join(ifempty(119.`related search`; emptyarray); \"|\")}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -578,
                            "y": -3312
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "Other"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "JSON - Parse JSON [119]"
                                }
                            },
                            "flags": {
                                "groupBy": {
                                    "collapsed": true
                                },
                                "stopIfEmpty": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            },
                            {
                                "name": "otherRowSeparator",
                                "type": "text",
                                "label": "Separator"
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                },
                {
                    "id": 121,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "name": "related search",
                        "scope": "roundtrip",
                        "value": "{{split(120.text; \"|\")}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -333,
                            "y": -3314
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "interface": [
                            {
                                "name": "related search",
                                "label": "related search",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
2 Likes

Hi Sam, I am new to Make.com and still learning it. can you please share the blueprint of the test case you’ve depicted above? I am not able to incorporate the logic into my scenario. Please note that I am using “array aggregator” output as input for the above two modules you have used. Its not working for me. can you elaborate a little?

I included the modules JSON export above with instructions.

2 Likes

The output JSON contains “related search” as an array which should look like this.

whereas as per your uploaded solution in the screenshot, the related search is a raw text.

Look at “related search” here.

Screenshot 2024-04-17 at 6.53.02 PM

Am I missing something here?

Maybe it’s better if you can just provide the output bundle of the HTTP module, with your scenario blueprint.

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

Cracked it finally!

Logic

Output

2 Likes

Hello @DroidKiller :wave:

Just wanted to give you a high-five for the great solution! :medal_sports:

Keep up the awesome job!

2 Likes