Use string variable result as sub path; no code.
Options
Kevin Wasie
Member ✭
I have a string variable.
I'd like to use that string value as the subpath of a variable in an "update variable function"
Can I do this somehow in Xano?
I need it to look something like this in no code, where I can use the result of foo as the sub path of module.
var foo = "bar";
$var.module[foo] = "something else";
// this would be the same as $var.module.bar = "something else"
(this is what I tried in Lambda, ^^ but I cannot update variables from inside the lambda function)
My use case: I'm looping looping through an array that has the keys to indicate what fields need updated. I need to then use that key on the subpath to set the variable.
I'd like to use that string value as the subpath of a variable in an "update variable function"
Can I do this somehow in Xano?
I need it to look something like this in no code, where I can use the result of foo as the sub path of module.
var foo = "bar";
$var.module[foo] = "something else";
// this would be the same as $var.module.bar = "something else"
(this is what I tried in Lambda, ^^ but I cannot update variables from inside the lambda function)
My use case: I'm looping looping through an array that has the keys to indicate what fields need updated. I need to then use that key on the subpath to set the variable.
Comments
-
-
Thanks for all your help. Maybe this screen shot below will help clarify what I'm wanting to do.
this is in a for loop with
array = ["a","b","c"]
for each fooBar in array {[Screen Shot 2022-04-21 at 10.51.35 AM.png]}
1) I do not know what the subpath is going to be that I need to update. It is stored in a variable as a string. In this case, called fooBar.
2) I then need to get the input with the name of the string value in fooBar.
I think I can figure out how to do the second step by creating an object, and possibly looping through, if I can figure out how to do the top part of setting the existing variable. -
Sounds like you may need the get and set filters. Each of them reference the root object and then you use dot notation (which can be from a variable) to either retrieve an element or set the object at the specified path.
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