Need assistance with dynamic array transformation

Hi!

I am encountering an issue when retrieving form submission data from an external source (Fillout), which is crucial for building reliable scenarios.

The submission data for form questions is returned as a sequential Array of collections. This means the questions are indexed by their position (e.g., 1, 2, 3…) in the form, not by a persistent identifier:

My current retrieval method relies on the position, which is fragile:

{{get(get(1.submission.questions; 3); "value")}}

If the form is modified (e.g., a new question is inserted), the question currently at index 3 will move to index 4, causing the scenario to pull the wrong data.

I need a reliable way to retrieve the answer based on the unique question ID (e.g., 1Vt1), regardless of its position in the array.

The ideal solution (or it is just my idea) is to transform the input array into a simple key-value map (or new array) where the question id is the key, and the value is the answer:

{ “1Vt1”: “value1”, “aZvn”: “value2” // … and so on }

Is it possible to easly do that? :slight_smile:

Hey Filip,

you can use the first(map() combo to find the questions dynamically using the name.

Like:
{{first(map(1.questions;value;name;Type your question here 1))}}

This will return the value where the name of the questions specifies the string you input. Or you can use the IDs as well instead of the name.

2 Likes

Hey!

Indeed, it seems that this is one of the solutions, and it works:

Thanks :slight_smile: This may be useful for others. I found another solution, which is the toCollection function that creates a collection of responses:

image