How to get a variable from a repeater (server-side)

How do I get a variable from within a repeater, on a higher level in that server action?

This is my setup:

image

I want to get {{action}} from repeater1 and {{gettype}} from repeater 2, into the variable “test” (bottom one).

I have tried {{repeat1.action}} and {{repeat1.repeat2.gettype}} but that produces null. Maybe it’s not possible because it’s a different level, but I still need to have this data separately to post something to my API destination.

I have also tried just selecting repeater1, but that outputs the entire repeat step. But I just need a few ones of the entire repeater.

Hope this makes sense

Edit: to clarify, lets say the repeater repeats 5 times. I then need an object with those 5 “rows”, in the highest level of the server action.

1 Like

Not sure in what format do you need the values in the ‘test’ variables, but you can apply the join formatter (available in collections menu) on the repeat expression.
character: ,
property: action

which will return result like:
action1, action2, action5 as a value.

Is it correct that the variables within the repeater are not visually selectable when using the join formatter?

It should be something like this then: {{repeat1.join(",", action)}}

Because that produces the following:

image

Yes, just enter the property manually. It will look like:

{{repeat1.join(",", "action")}}
1 Like

Ah so action should be a string? I thought it was an identifier, since it’s referring to a set value.

Still I think it would be even better if I could just visually select a variable from within a repeater, in the root level. Is that something that can be built out in the UI eventually?

Thanks for your quick help!

Hi @Teodor ,

This isn’t panning out as I’ve hoped. I actually want repeat2 (which is inside repeat1) as an array, not joined together. I can retrieve repeat1 as an array, just not the repeat2 level inside.

I would have assumed that something like {{repeat1.repeat2}} should work, but it doesn’t.

Maybe you can look at this question broader, is it somehow possible to have the nested levels available on the root level? Maybe it’s by design, I don’t know. But that’s really what I need in this case, to have a nested level usable in root level.

The repeaters return an array, to access an item inside the array you need to access it by its index like repeat1[0]. Repeat2 from the first item is then accessed as repeat1[0].repeat2.

1 Like