Can I ditch this loop? Or better?
Options
![Mitch](https://us.v-cdn.net/6037124/user_avatars/2157194.jpg)
Mitch
Member ✭
Just curious if any of the recent updates (or gaps in my knowledge) can simplify this...
A user selects multiple tags from a list. Those tags relate to the "name" field of a tag database. And because of a limitation on my front-end, Xano gets sent an array of tag.name instead of tag.id.
Ultimately, I'm trying to add that array of chosen tags to a session table with a field referencing the tag database.
My questions:
1. Right now I query the tag database to get the associated records based on the name... then loop through that to get the tag.id and push it into a new variable that I can push to the session table. Is there a way to do this without looping and pushing my way to an array of integers?
2. Even better... is there a way to add the tags to the session table using tag.name instead of converting it to tag.id?
Thanks!
A user selects multiple tags from a list. Those tags relate to the "name" field of a tag database. And because of a limitation on my front-end, Xano gets sent an array of tag.name instead of tag.id.
Ultimately, I'm trying to add that array of chosen tags to a session table with a field referencing the tag database.
My questions:
1. Right now I query the tag database to get the associated records based on the name... then loop through that to get the tag.id and push it into a new variable that I can push to the session table. Is there a way to do this without looping and pushing my way to an array of integers?
2. Even better... is there a way to add the tags to the session table using tag.name instead of converting it to tag.id?
Thanks!
Comments
-
- If I'm understand correctly, you definitely will need a loop but you might be able to optimize it to one single For Each Loop.
First, create a variable that is an empty array
For Each Loop through your received tag names
Get Record by name for each tag name in the loop
Array: Add to end of Array output of get record var.id to the empty array var
Edit Record (map the array var to the table reference list in your table)
[CleanShot 2022-02-17 at 10.51.41.png] -
Thanks, . That's how I went ahead and did it.
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