Set variable fails when array aggregator has a value

:bullseye: What is your goal?

I want to set a variable from the output of an array aggregator which output consist of a bundle of 5 items. This variable should be a randomly set from 1 of these 5 items.

:thinking: What is the problem & what have you tried?

This scenario gets executed fine most of the times but sometimes it can’t set a variable even though there’s a valid output if 5 items from the array aggregator. See attached screenshot to see the output of Operation 5. Each bundle of this operation has a value assigned to Sce.Large which is the field used to set the variable. Instead of setting the variable it returns an empty value.

:clipboard: Error messages or input/output bundles

A

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey Niels,

can you please add the formula to a set variables module and then check what the random number generated was and compare it to the input bundle and what the value was supposed to be?

Hallo Niels,

There is a tiny mistake in the random formula that you use. Make indexes arrays starting from 1, not from 0. The result of your function may be zero and is never five. When it is 0, the result is that you pick the 0 index of the array, which leads to no result.

Try {{floor(random * 5 + 1)}}

Cheers,
Henk

Ah that makes total sense Henk! I’ll change the formula and it should be fixed then. Thanks a lot.

Please let us know if it worked!

It did Henk, just had a single run with 20 operations and all worked flawlessly!

1 Like