Formula to set a page variable not working

I’m attempting to use this formula:

LOOKUP(FIND(data.Country.fields.Images, index == 1), “url”) to extract a URL from an array.

In the formula editor I get exactly the example result I want and the validation gives me a tick, but the page variable stays stubbornly as ‘undefined’.

What can I do?

Remember that index starts from 0. Also are you sure that there is an object at index 1 (i.e. the second element of your array) at that point of your code execution ( so that you dont try to access the object before its even loaded from the backend)

So - there definitely is an object at index 1 (the example result is exactly what I want the variable to be) - but the second point is interesting. Is there any sort of notification that the backend has finished loading that I can use as a trigger to try and populate that variable?

I assume you are using a data variable? There’s default polling logic that can be viewed/edited when you select the data variable in the variables editor and open the logic canvas for it.

That way, you could add a pageVars.dataLoaded boolean once the data has been set to the data variable.

Alternatively, you can use e.g. IS_EMPTY(data.Country) to see if the data variable has data.

I’ve resolved the issue - I think I was just using a formula that wasn’t working!!! MAP is my friend.

Can you please share what you changed in the formula? I’m stuck in exactly same problem.

I’m afraid that was 2 years ago - so I’ve totally forgotten what I did - really sorry about that.

But from reading though - I think i gave up on the Lookup and used MAP instead.


Thank you :). Can well imagine.

Variables cannot be set or altered through Formula.
Same thing is mentioned in Variables and formulas: Videos
Go to - “Using Variables” Video (Part 6)
It is mentioned at 1:03 minutes duration.