How to avoid error "Unable to locate var" when the variable is not created?
![pachocastillosr](https://us.v-cdn.net/6037124/uploads/userpics/MC7ELS8NG1HC/nPLP98RNMYYEZ.jpg)
Hi,
My function stack, in a loop, sometimes create a variable object called "final_variant_records_with_errors". Sometimes it doesn't (this is intended).
I need to reference "final_variant_records_with_errors" later in the loop, only if has been created.
The problem is, if it was not created, Xano would return error "Unable to find var".
I tried this without success:
Is there a solution to this that doesn't involves creating an empty variable for each loop?
Any help would be appreciated. Thanks!
Answers
-
Using a GET filter is going to be the best way to get a value in a chain while simultaneously preventing errors for the value if it doesn't exist. What you're doing looks like the best way to achieve this. But just so I understand correctly, you want to
1) Loop through your data
2) Sometimes create, and sometimes not create, afinal_variant_records_with_errors
object variable.
3) Reference thefinal_variant_records_with_errors
object variable if it's been created.
You can continue to use the GET Filter, but it also sounds like that within this function stack, a conditional can be used to route the logic based on the argument that thefinal_variant_records_with_errors
object variable exists.
Let me know if this helps at all or what else I can assist with :) -
Thanks for replying @Cameron B . You understand correctly.
Regarding your suggestion about the conditional, which would be the condition that you suggest?
I've tried using conditional IF "final_variant_records_with_errors" is not empty, but that can't run if "final_variant_records_with_errors" do not exists (since it has nothing to evaluate), so it returns the same error "Unable to locate var".
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback