Local Variable not refreshing inside forEach
Ok so, inside a forEach statement I define a local variable like so:
a!localVariables(
local!routingChoices: a!refreshVariable(
value: if(
a!isNotNullOrEmpty(ri!inputData[local!currentIndex].routingAction[fv!index]),
a!match(
value: ri!inputData[local!currentIndex].routingAction[fv!index],
equals: 6,
then: {1,2},
equals: 7,
then: {1,3},
equals: 8,
then: {2,4},
equals: 9,
then: {2,3},
equals: 10,
then: {3,4},
equals: 11,
then: {1,2,3},
equals: 12,
then: {2,3,4},
default: fv!value
),
null()
),
refreshOnReferencedVarChange: false(),
refreshOnVarChange: local!sealCount
),
local!sealCount stores an integer and the forEach is set up to run "enumerate(local!sealCount)" times (so if local!sealCount = 2 the forEach runs twice).
Then, farther down in the interface, I have a dynamic link that acts as a "delete" button (it subtracts 1 from local!sealCount and deletes the data in ri!inputData that corresponds to the index being deleted).
I also have an "add" button that is also created with a dynamic link that adds 1 to local!sealCount and appends a null() value to the fields in ri!inputData.
The problem I'm running into is that, when I add a component with the add button, put some data into local!routingChoices (via a card selection component), delete that component with the delete button, and then add a component again, the data that I put into local!routingChoices is still there. However, I expected it to be null() because ri!inputData[local!currentIndex].routingAction[fv!index] = null() and local!sealCount changed so the local variable should re-evaluate.
Here's a simplified chain of events:
1) Click "add" button (sealCount = 2 now)
2) Save data to routingChoices and inputData
3) Click "delete" button for that component (sealCount = 1 now)
4) Click "add" button again (sealCount = 2 now) <-- routingChoices expected to be null() but instead retains values from step 2
Can anyone help me understand what is going on here and how to fix it so that, when the "add" button is pressed routingChoices will be null()?
(Also, if you need to ask for clarification on something definitely feel free)
Thank you!
