Conditional slice doesn't work in formula

Hello the team,

I used a Javascript snippet to fix this, but just as a notice if you want to fix it : when using an “if” in a Formula binding to iterate on a collection items with a slice, i get the error “(intermediate value) is not iterable” - which is logic in itself, because the object is null. But, according to how “if” works, it should NOT evaluate this expression (I guess).

Here the first case where is works fine cause I’m in the “not null” case. An empty choice is added :

And there the null case :

Thanks God and your team that Weweb exists <3

Hi ! Thanks for your kind words :slight_smile:

Our IF is a javascript function so every parameter are passed and evaluated before ending inside a ternary it looks like this

if(cond, iftrue, iffalse) {
    return cond ? iftrue : iffalse;
},

Instead you can write directly a ternary inside the formula

item.data.choices ? [...item.data.choices, ''] : ['']
1 Like