Lookup function issue

Hi,

This block should check if there is an Active Shift for the driver (stored var).

If there isn’t one, it does go to ELSE. (happy days!)

If there is an active shift though, it:

  • starts with DO (shows the start button and hides the rest)
  • then goes to ELSE (hides start button and shows the rest as it should)
  • then goes back to DO

I am using Google sheets and the shifts table at the moment has 1 or up to 3 records from which the last one might be Active for test purposes.

That is the main issue.

The second issue would be that this one alone takes a good few seconds to run.
Is there a faster way to get as close as possible to “instant” or is this a Thunkable limitation?

You described the details about the main issue but… what is your question?

As far as speed goes, it’s going to be slow because you are accessing a stored variable in a loop. Every access takes a while. You need to use an app variable in the loop instead. So, assign the stored variable value to an app variable. Only use stored variables when you need to load the value into an app variable (when screen opens) or when you change the value of the variable. Any time you are just accessing the variable’s value, use the app variable because it is much faster.

1 Like

thank you for your quick reply.

Something in my blocks is wrong. It does not behave as expected.
If I have an active shift it doesn’t stay on the DO branch. even if does for a moment, the loop ends on the ELSE branch

There is sometimes a bug with the Get Value block. It may not be returning current values from your data source. See this: Get value from Google Sheet not updating properly · Issue #1138 · thunkable/thunkable-issues · GitHub

1 Like

Then my blocks look OK to you?

I’ve replaced it with this to avoid the get value block and added an app variable to use it for the loop.
Still not working. This one doesn’t even go on DO, goes straight to ELSE.
Time-wise, same thing, a good few seconds to run the loop and that with 3 records (2 Completed and 1 Active)

It takes several seconds to run that loop?! What happens if you remove the two custom “view” functions from the loop? Does it still take several seconds? It shouldn’t. It should be almost instantaneous. And if it’s much faster without them, then it’s the content of those two functions that is slowing things down.

Those functions are “nothing”

image

1 Like

That really surprises me that a loop with three items would take even 1/2 a second. Any chance you can share a link to your project? I feel like there must be something else causing that delay.

sent it. check pm

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.