Nested arrays and collections

I need to get the value “Diretor”, but im not getting any value with the mappings that im coding, can someone help?

Use Set Variable
Flatten the array → flatten([child_relations],6)

Then you can use the map function.

It does not work becase there are arrays and collections between each other :c

I’m posting down here the output of an GraphQL query that im using to get the information via API

I Want to get the “value” field from the “Responsável pelo departamento” name collection

[
    {
        "body": {
            "data": {
                "organizations": [
                    {
                        "id": "xxxxxx",
                        "name": "xxxxx"
                    }
                ],
                "card": {
                    "title": "XXXXXX",
                    "assignees": [],
                    "comments": [],
                    "phases_history": [
                        {
                            "phase": {
                                "name": "Start form"
                            },
                            "firstTimeIn": "2024-10-03T01:03:10+00:00",
                            "lastTimeOut": "2024-10-03T01:03:11+00:00"
                        },
                        {
                            "phase": {
                                "name": "Aprovação"
                            },
                            "firstTimeIn": "2024-10-03T01:03:11+00:00",
                            "lastTimeOut": null
                        }
                    ],
                    "url": "XXXXXX",
                    "emailMessagingAddress": "XXXXXXX",
                    "comments_count": 0,
                    "current_phase": {
                        "name": "Aprovação"
                    },
                    "done": false,
                    "due_date": null,
                    "fields": [
                        {
                            "name": "Solicitante",
                            "value": "[\"XXXXX"]",
                            "date_value": null,
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": [
                                "XXXXX"
                            ]
                        },
                        {
                            "name": "Tipo de solicitação de Home Office",
                            "value": "Solicitação atípica",
                            "date_value": null,
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": null
                        },
                        {
                            "name": "Qual o motivo do Home Office?",
                            "value": "Condição de saúde",
                            "date_value": null,
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": null
                        },
                        {
                            "name": "Justificativa da solicitação",
                            "value": "SSDS",
                            "date_value": null,
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": null
                        },
                        {
                            "name": "Turno do Home Office",
                            "value": "Integral",
                            "date_value": null,
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": null
                        },
                        {
                            "name": "Data do Home Office",
                            "value": "03/10/2024",
                            "date_value": "2024-10-03",
                            "filled_at": "2024-10-03T01:03:10Z",
                            "array_value": null
                        }
                    ],
                    "labels": [],
                    "child_relations": [
                        {
                            "cards": [
                                {
                                    "child_relations": [
                                        {
                                            "cards": [
                                                {
                                                    "child_relations": [
                                                        {
                                                            "cards": [
                                                                {
                                                                    "fields": [
                                                                        {
                                                                            "value": "Diretor",
                                                                            "name": "Nome da função",
                                                                            "float_value": null
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "cards": []
                                                        },
                                                        {
                                                            "cards": [
                                                                {
                                                                    "fields": [
                                                                        {
                                                                            "value": "Departamento de projetos",
                                                                            "name": "Departamento",
                                                                            "float_value": null
                                                                        },
                                                                        {
                                                                            "value": "[\"Felipe Almeida\"]",
                                                                            "name": "Responsável pelo departamento",
                                                                            "float_value": null
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ],
                                                    "fields": [
                                                        {
                                                            "name": "Nome da função detalhada",
                                                            "value": "Diretor de projetos",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": null
                                                        },
                                                        {
                                                            "name": "Função geral relativa",
                                                            "value": "[\"Diretor\"]",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": [
                                                                "986487198"
                                                            ]
                                                        },
                                                        {
                                                            "name": "Departamento de alocação da função",
                                                            "value": "[\"Departamento de projetos\"]",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": [
                                                                "974091506"
                                                            ]
                                                        }
                                                    ]
                                                },
                                                {
                                                    "child_relations": [
                                                        {
                                                            "cards": [
                                                                {
                                                                    "fields": [
                                                                        {
                                                                            "value": "Diretor",
                                                                            "name": "Nome da função",
                                                                            "float_value": null
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "cards": []
                                                        },
                                                        {
                                                            "cards": [
                                                                {
                                                                    "fields": [
                                                                        {
                                                                            "value": "Departamento de tecnologia e inovação",
                                                                            "name": "Departamento",
                                                                            "float_value": null
                                                                        },
                                                                        {
                                                                            "value": "[\"Felipe Almeida\"]",
                                                                            "name": "Responsável pelo departamento",
                                                                            "float_value": null
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ],
                                                    "fields": [
                                                        {
                                                            "name": "Função geral relativa",
                                                            "value": "[\"Diretor\"]",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": [
                                                                "986487198"
                                                            ]
                                                        },
                                                        {
                                                            "name": "Departamento de alocação da função",
                                                            "value": "[\"Departamento de tecnologia e inovação\"]",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": [
                                                                "974091571"
                                                            ]
                                                        },
                                                        {
                                                            "name": "Nome da função detalhada",
                                                            "value": "Diretor de tecnologia e inovação",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": null
                                                        }
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "cards": [
                                                {
                                                    "child_relations": [
                                                        {
                                                            "cards": []
                                                        },
                                                        {
                                                            "cards": []
                                                        },
                                                        {
                                                            "cards": []
                                                        }
                                                    ],
                                                    "fields": [
                                                        {
                                                            "name": "Cargo",
                                                            "value": "Diretor De Planejamento Estrategico",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": null
                                                        },
                                                        {
                                                            "name": "CBO",
                                                            "value": "121005",
                                                            "float_value": null,
                                                            "date_value": null,
                                                            "array_value": null
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ],
                                    "fields": [
                                        {
                                            "value": "Sim",
                                            "name": "Possui bônus fixo?",
                                            "float_value": null,
                                            "date_value": null,
                                            "array_value": null
                                        },
                                    
                                        {
                                            "value": "Ativo",
                                            "name": "Status",
                                            "float_value": null,
                                            "date_value": null,
                                            "array_value": null
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            }
        },
        "headers": {
            "date": "Thu, 03 Oct 2024 01:03:11 GMT",
            "content-type": "XXXX",
            "transfer-encoding": "chunked",
            "connection": "close",
            "x-frame-options": "XXXX",
            "x-download-options": "noopen",
            "x-permitted-cross-domain-policies": "none",
            "referrer-policy": "XXXXX",
            "content-disposition": "XXXXXXXX",
            "vary": "Accept-Encoding, Origin",
            "etag": "X",XXX
            "cache-control": "max-age=0, private, must-revalidate",
            "x-request-id": "XXXXX",
            "x-runtime": "XXXXX",
         
            "x-xss-protection": "1; mode=block",
            "x-content-type-options": "nosniff",
            "cf-cache-status": "DYNAMIC",
           
            "cf-ray": "XXXX"
        },
        "statusCode": 200
    }
]

Did you try nesting map and flatten?


Created this structure.

Output

Used this

Let me know if this works.

1 Like

It worked!! thank you, i didnt construct the funcion like that when i tryed, its a nesting flattens within maps and flattens haha

the result that i wanted:

image

the final function:

image

i wish i could eliminate the need of specifing the number of the collection between the “assignee_values” and “id”, so that i could get an array of multiple assignees within the collection.

explaning better:

i want to get the “assignee_values” ID value based on the “name” from the parent collection, like:

map(“array”;assignee_values.id;name;“Responsável pelo departamento”)

if i’m not abusing, do you have a little soluction for that? i tryed some soluctions, but i just got it specifing the number of the collection, like this: “assignee_values.1.id”

Try wrapping that in a ‘get’ function.

I tried to replicate your structure:

Formula I used:

Result:

Hope this helps!

1 Like

Good afternoon!, I tryed some other solutions but i couldnt make so i could be able to not specify the colection, in your solution, you specify it too, before the “id” field, but i can manage the database options to work with this condition. so its fine!
overall thank you very much for your first solution, it helped me a lot!, im gonna set it as the solution.