Combining LOOKUP + PICK ITEM Formulas

Does anyone know why this formula won’t work?
LOOKUP(PICK_ITEM(data.Activities, 1), “name”)

I also tried with an extra set of parentheses:
LOOKUP((PICK_ITEM(data.Activities, 1)), “name”)

The formula previewer shows it should work, but when I test using it to populate a page variable, it doesn’t carry any information through. (I am successfully getting data from the data source on another page, so I don’t think the data source is the issue.)

App 98690
Page Welcome Activities Single 1

CONTEXT
My data source Activities is a list of activities a user can do. I want to show activities one at a time and have the user click to add the activity or pass.

The time it takes to post the user’s response and generate the next activity to show is a bit longer than I want, so I’m caching the upcoming activity as an App Variable so it can be pulled instantaneously while I process the previous records.

Here, I’m pulling just the second-from-the-top object from the data variable array (because they’re currently looking at the top one) and specifying the piece of data that I want to save into the app variable.

The debugger indicates that it’s trying to save something (the variables show up in the State app variables list, so they did get touched), they just didn’t have any data put in.

Looking at your code, there’s a race condition – when your Page mounted logic fires and the Set app variable nodes are triggered, data.Activities is not yet populated from the backend.

If the activities data is the same app-wide, you could store it to an app variable in global canvas so it’s always available – that requires manually duplicating the data polling logic in the global canvas and the data schema into the app variable.

Yep, that did the trick. Thank you so much!

1 Like