Can I ditch this loop? Or better?

Options
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!

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     - 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]
  • Mitch
    Mitch Member
    Options
    Thanks, . That's how I went ahead and did it.