How to Extract and Concatenate Values from a Nested Array of Collections

Captura de Tela 2024-09-03 às 14.45.27
I have a GET module that returns an array containing an indefinite number of collections. Inside each of these collections, there is a plain_text value that I need to extract. My goal is to create a variable that contains all these plain_text values concatenated into a single line. I’ve tried using the formula join(map(array; item within the collection); -), but it’s not working. How can I correctly extract all these plain_text values and combine them into one string variable?

Welcome to the Make community!

You can use the built-in function map before join

e.g.:

{{ join(map(1.contexto; "plain_text"); "-") }}

If you need further assistance, please provide the following:

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”.

A. Upload as Text File

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

B. Insert as Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

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!

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

1 Like

Hello! Thank you very much for the help! So, I tried using this method as shown in the screenshots, but I still can’t get the desired result. The number of collections in the ‘Contexto’ array is indeterminate. I would just like to create a variable with all the plain_text values.

            "Contexto": [
                {
                    "type": "text",
                    "text": {
                        "content": "Metas da semana:",
                        "link": null
                    },
                    "annotations": {
                        "bold": true,
                        "italic": false,
                        "strikethrough": false,
                        "underline": false,
                        "code": false,
                        "color": "default"
                    },
                    "plain_text": "Metas da semana:",
                    "href": null
                },
                {
                    "type": "text",
                    "text": {
                        "content": "\n• Seguir planejamento, journaling e manter o foco.\n• Criação da versão 1 da IA Pessoal\n• Análise/estudos sobre a estratégia de captação de clientes",
                        "link": null
                    },
                    "annotations": {
                        "bold": false,
                        "italic": false,
                        "strikethrough": false,
                        "underline": false,
                        "code": false,
                        "color": "default"
                    },
                    "plain_text": "\n• Seguir planejamento, journaling e manter o foco.\n• Criação da versão 1 da IA Pessoal\n• Análise/estudos sobre a estratégia de captação de clientes",
                    "href": null
                },
                {
                    "type": "text",
                    "text": {
                        "content": "\nObjetivos:",
                        "link": null
                    },
                    "annotations": {
                        "bold": true,
                        "italic": false,
                        "strikethrough": false,
                        "underline": false,
                        "code": false,
                        "color": "default"
                    },
                    "plain_text": "\nObjetivos:",
                    "href": null
                },
                {
                    "type": "text",
                    "text": {
                        "content": "\nSinta-se a vontade para escrever sobre o que quiser, que seja importante para a avaliação de desempenho e progressão. Foque em dados pertinentes para avaliar o segmentos das leis do coelho, a conclusão das metas e as expectativas/realidade de cada tarefa realizada. Isso será de extrema importância para que seja avaliado o grau de desempenho e evolução para que o tempo gasto em cada projetos não seja o fator mais importante.",
                        "link": null
                    },
                    "annotations": {
                        "bold": false,
                        "italic": false,
                        "strikethrough": false,
                        "underline": false,
                        "code": false,
                        "color": "default"
                    },
                    "plain_text": "\nSinta-se a vontade para escrever sobre o que quiser, que seja importante para a avaliação de desempenho e progressão. Foque em dados pertinentes para avaliar o segmentos das leis do coelho, a conclusão das metas e as expectativas/realidade de cada tarefa realizada. Isso será de extrema importância para que seja avaliado o grau de desempenho e evolução para que o tempo gasto em cada projetos não seja o fator mais importante.",
                    "href": null
                }
            ],

You actually have to manually TYPE in character-by-character plain_text, and NOT select the variable from the panel.

Screenshot_2024-09-05_090943

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

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!