Unable to Access Variable Properties in Repeated List Labels/Images

Hi,

This thing is driving me crazy right now, and I really want to know if I’m doing something wrong or if it’s a bug.

Problem:

  • I have an Image List Item that repeats based on a fixed list of objects. Each item in the list is a single key-value pair. (E.g.: [{"a": "b"}, {"c": "d"}].) The properties of the Image List Item reference the currently repeated value as “me_eq”.
  • I have a data variable called “me_countryData” that contains an integer value for each key in the fixed list (e.g., {{"a": "3"}, {"c": "2"}} – but slightly more complicated because it’s in Firebase schema format)
  • By referring to the data variable and to the key of the key-value pair that’s being currently repeated, I am able to set the visibility of my list item just fine. Specifically, this formula resolves correctly in a True/False value to set visibility: INTEGER(LOOKUP(LOOKUP(data.me_countryData.fields.equipment.mapValue.fields, KEYS(repeated.me_eq)[0]), "integerValue")) > 0
  • However, using the exact same variable and key reference, I am unable to set the list item’s secondary field or image. I’ll use the secondary field example because it’s simpler: LOOKUP(LOOKUP(data.me_countryData.fields.equipment.mapValue.fields, KEYS(repeated.me_eq)[0]), "integerValue") + "/3 pcs" results in "undefined/3 pcs."

I thought that maybe the issue was with Data Variables themselves, so I tried using a Page Variable with a simplified (name:integer) schema as an intermediary: LOOKUP(pageVars.me_eq, KEYS(repeated.me_eq)[0])+"/3 pcs". That failed too.

Screen Shot 2020-10-12 at 7.56.00 PM

It appears that the problem is with any variable that is set or changed after the component itself loads. Even when I try to make the secondary field display something based on the simplest variable in the world (a text-only page variable that I set to “test” when the page loads), it will just show up as blank. App variables set by the global canvas via URL parameters when the app is initially opened work fine.

Workaround:

I was especially puzzled because essentially the exact same formula works beautifully in another part of the page.
Screen Shot 2020-10-12 at 8.33.21 PM

These list items are themselves inside repeating containers, so the formula there looks like this:
LOOKUP(LOOKUP(repeated.currentCountry.fields.equipment.mapValue.fields, KEYS(repeated.eq)[0]), "integerValue")+"/3 pcs"

So, my workaround ended up being that I wrapped the misbehaving list in its own repeating container (a list of all “country” objects), limiting the container to a single item (the “country” object whose data I wanted to reference).

However it took me about an hour to figure out that this would solve the problem. Was there a better way to go about this? Is this a mistake I am making or is this an AppGyver bug?

I found a help topic about a similar issue, but @Harri_Sarsa’s response at the time seemed to indicate that the issue was confined to a very specific subset of formulas, not to the very wide array of variable references that I found were not working for me.

Thanks,
Ethan

It’s hard to say what the problem here could be, so let’s see if there are some ways to pinpoint.

One way to try debugging this is using ENCODE_JSON to see what value is passed to the Formulas for real. You could try to use this with first only parts of your then add another Formula layer around it and see when the value becomes undefined.

One thing that caught my eye was this:

I think with current runtime, it’s necessary to update the whole variable not just a field of it in order to re-render the repeated content. The upcoming major update to our runtime should improve this aspect also.

I didn’t really understand how the “ENCODE_JSON” debugging process you referred to was meant to be done, so I did some more debugging the slow&painful way, and I have more specifics on this problem for you, as well as a possible workaround!

It seems that when you have a repeated element where the “Repeat As” is based on a variable, any repeated items nested inside the top-level repeated element will not dynamically update unless the top-level “Repeat As” also updates.

To illustrate:

  • I have a repeating Container A, which is repeated based on the values of Data Variable A (a list).
  • Inside each instance of the container is a repeating List B, which is repeated based on the values of Data Variable B (another list).
  • On page load, if I set Data Variable A before I set Data Variable B, my nested list elements will not load unless something about Data Variable A changes (thus updating a top-level Container A).
  • Conversely, if I set Data Variable B and then Data Variable A, my nest list elements will load!

I think this is probably the same problem that @Marco_Boretto was solving by adding a delay before setting one of his variables, as he described in this thread.

Yep, we know this issue exists with the current runtime, but the new runtime which is in Beta now should tackle this issue. Basically now you need to set the whole variable that’s repeated to re-render the list as the re-rendering won’t happen if you set only properties within the repeated variable.