Switch not working in text aggregator

Hello, I’m new to Make so this is probably something silly I’ve missed.

I am sure this was working, as I’ve checked the run history and it had succeeded last time I ran it.

I have a text aggregator that I’m using to pull together answers from a form into sections.

The below switch is on the text aggregator - this is a shortened version I’m using for debugging.

{{switch(first(map(3.fields; “field_type”; “field_id”; 126.key)); “text”; "Text_type " + map(3.fields; “field_value”; “field_id”; 126.key); “list_multiple”; map(3.fields; “field_label”; “field_id”; 126.key) + newline + join(map(first(map(3.fields; “field_value.options”; “field_id”; 126.key)); “name”); “,” + space); “everythingelse”)}}

The list_multiple result is not working. I get the error:

Failed to map ‘value’: Function ‘switch’ finished with error! Function ‘join’ finished with error! Function ‘map’ finished with error! ‘This is what i do for fun’ is not a valid array.

“this is what I do for fun” is the result of the first collection but field_type for that question is “text”.

Here is the part that is breaking it:

{{join(map(first(map(3.fields; “field_value.options”; “field_id”; 126.key)); “name”); “,” + space)}}

It’s the outside map that should be returning the options.name that seems to be breaking it.

When the outside map is removed I get returned the three objects

image

If I use a filter to only send the list_multiple field_types it works as expected so I’m wondering if the problem is with my switch

I am sure this was working, as I’ve checked the run history and it succeeded, I’ve reverted to the saves around that run and it now doesn’t work.

The data:

The iterator the text aggregator is connected to

1 Like

Hey @Reginald Welcome to the community!

Formula prepared with any function will return error if mapped values are empty or N/A. so always make sure when you run the setup, all the necessary mapped items are present for formula to work as expected.

Best,
@Prem_Patel

Thanks @Prem_Patel just so I understand, if the field_type is text, then there is no field_value.options so that would cause the error? I was of the understanding that the switch would see the value was text and run that case, not try and run the list_multiple case.

I’ve used nested if()’s now instead of switch and it seems to be working.

Thanks again

1 Like

using If and if empty when the values might be present or empty helps a lot. Also pairing them with filter to avoid if’s failure when values are empty, that too might help.

Best,
@Prem_Patel