Dynamic variable name in custom function
Options
prolet
Member ✭
Hi,
I could not figure out how to do this or if it is even possible.
What I need:
- Ability to name a variable based on the input in a custom function, so I can reuse a function with multiple calls and return a new list of items.
- The function goes through a loop and in the loop I want to be able to name the variable that is to be returned with a new name that I specify
So for example if I pass a list of items with this structure:
{ "name": "Name Goes here", "value": 1293} and I call the function with this as an input along with a string as var_name of "amount".
I want to return :{ "name": "Name Goes here", "amount": 1293}
The issue is that in the loop of items I use "item" and there does not seems to be something like eval("item." + input_var_name ).
is this somethign even possible? I can do it with a different structure but this would be nice
Thanks!
Comments
-
@prolet is this what you are trying to do?
-
@arturosanz exactly what I needed. Thank you!
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