Flex Repeater - Output param in view not matching instances array

Issue is on a form that contains a flex repeater where the repeated view is a dynamic number of rows containing a text string, checkbox, and comment field. It is possible to save and reload the form so the checkbox is sometimes checked by the user and sometimes checked by a startup script that sets the props.selected value to the saved value.

The repeated view has an input parameter Value used to set the initial value for the checkbox and an output parameter CurrentSelection bound to Checkbox.props.selected. The startup works in that if Value is set to True the checkbox will appear checked and if I then log the value of current selection it shows as true.

A script on the main form iterates through the flex repeater instances array after a save button is clicked and reads CurrentSelection for each instance. However the script will only read CurrentSelection as being true if the checkbox was checked by clicking on it - if it was set by the startup script it will read the initial default value set in the instances array (which I set to -999).

Version is 8.1.1. I saw people had similar issues on earlier versions, I tried upgrading a test environment to 8.1.7 but this did not resolve the issue.

How is the initial value written to the component? I’m betting there’s a race condition where the initial value code is the last to run and hence overwriting the script that sets it to the saved value

The initial value is set by creating a new instances array for the flex repeater in the script that reloads the form and setting the ‘Value’ parameter in each.

Nothing should be setting the Value parameter after initialization and only the CheckboxRow startup script should be pushing the Value parameter to the props.selected of the checkbox.

I put a log message of the ‘CurrentSelection’ output parameter that is bound (unidirectional) to props.selected at the end of the startup script after a 2 second sleep and it always matches the initial Value parameter. However when ‘CurrentSelection’ is read by looking for CheckboxFlexRepeater.props.instances[“CurrentSelection”] it does not match the logged value

I had this exact issue. The only way I found to solve it was by actually setting it to the correct value :confused: it’s a bit horrible… I posted about it, can’t remember if I got any hits at the time. But the expressions in my instances that used my initial values didnt seem to always re-evaluate from the initial value I’d set. It would maybe 70% of the time

1 Like

Inductive support analyzed the code, the following fix was found to clear the issue.:

-When setting the instances array of the flex repeater always clear it first by setting it to []
-Create the new instances in an array and then set instances to the new array. Do not call the add method on the instances array directly.

1 Like