I am trying to save a set of specific values from a repeat in order to do some validation.
To simplify here is what I want to do :
Repeat 1 :
Repeat 2 :
Repeat 3 :
Outside of the repeat I want to store the Q3 value in one variable (call it store_ph_7) if Q1 = ph and Q2 = 7 and in another variable (call it store_ph_4) store the Q3 value for Q1 = ph and Q2 = 4
Then I have a note popping up if X - Y > 1
Is there a way to do this? Repeats will never be in the same order and the actual form have way more options so I can't rely on counts or indexes.
I based my structure on the assumption that I could store any value from the repeat using a set of relevant rules but apparently it doesn't work that way. I tried using once() but that didn't work either.
Anyone has a clever trick to do this?
I found two work arounds, and implemented one. But please let me know if there is something easier!
The second solution I have found, which only works because I have only three values to store is using join. Using an if in my calculation within the repeat, I insure that only one value will be returned for all the repeats iteration. The join outside of the repeat will then only have one value to join and will have stored the data I need. Here is an image showing the mess :
Not pretty but it works, I am sure there are better way to do this so let me know 😄
From Ismael's blog :
function HasDups (myArray)
return new Set(myArray).size !== myArray.length;