Help with lookup formula

I have a field inside another table with the corresponding id in Supabase. I’m trying to use the lookup function in WeWeb to display the name of the item matching the id. This formula works on all others, but this one I can’t seem to get.

Am I overlooking something?

RLS is set to select for all, so just public on all tables. It’s a local version I’m using to test with.

1 Like

Hi @Lantzgould :wave:

Can you show us the current value when you remove the . name at the end of the formula?

Hey @Joyce,

Comes to undefined when removing the .name.

If I do a basic lookup on that table, I can grab the id no problem. Just when using it in this case I get the error and I’m a bit stumped.

Have you seen this video? https://youtu.be/gu-YA606_24

If you have, I would make sure to take it step by step to make sure your first lookup formula returns a value and then your getKeyValue formula that’s wrapped around it returns the result you expect and then the second lookup formula does to.

For example, I asked you to remove the .name because I suspected the formula didn’t return any data (and thus it didn’t make sense to look for the name inside an object since there was no object).

Does that make sense?

Sorry, it’s a bit hard to explain in writing but hopefully the video helps!

Hey @Joyce,

Thank you, yes I’ve seen the video. Interestingly, I can grab the id of the vehicle_model, but cannot grab the name which is in the same table.

I think you’re either not fetching it, or it’s nested. But might be wrong, I’d need to see the data structure. (Tables)

Thanks for taking a look, @Broberto.

Here’s what the setup looks like in Supabase:

Citations Table

Vehicle Model Table

Any help is appreciated.

Hmm can you show how you’re grabbing the name with the formula?

Sure, here’s a simple lookup using the first id from the list as an example:

And here’s what it looks like looking at the object without the name:

Anyone else out there that might be able to assist? :slightly_smiling_face:

This looks like a great start:

From what I understand, you would like to get the value of name, correct?

If that’s the case, then adding .name or ["name"] at the end of the formula above, after the parenthesis that closes the lookup, should work.

Thanks @Joyce.

Maybe I’ll submit a bug report, as these both still are returning errors on the simple lookup formula. The first of using .name returns

Cannot read properties of undefined (reading ‘name’)

and using the ["name"] returns

Invalid or unexpected token

I suspect something with the schema from my specific table in Supabase is not in sync with WeWeb, as the rest of them work without any issues. :thinking:

Hello, I’m kind of dealing with the same issue : “undefined” result when trying to use a lookup.
Within a card from collection list (called “Remises”), I would like to display the name of a “Concession”, based on the id of a “Concession”, that is included in the “Remises” collection.
But I get this undefined result …
Capture d'écran 2024-05-13 172610
Any ideas ?
I’m using Supabase as a backend and here is a quick view of the schema :
Capture d'écran 2024-05-13 173306
Thanks !

EDIT : I managed to retrieve the info that I want thanks to the advanced method (directly when creating collection), but I would like to understand what am I doing wrong with lookup formula

Try to use Concession instead of Concession.data, what do you get ?

The same !
Capture d'écran 2024-05-13 183733

Use the log action to see inside the item and the collection variables. That will let you reason about. What you want to search and for what. If it’s not clear, share the results so others in the forum can point you in the right direction. “Inputs and outputs” is a key mental model at state change for cracking complex and non obvious problems.

As suggested by @raydeck you can try to display the current value of the purple and blue variable

You can remove the lookup end only keep item.data.concession_id so it will display the value, then the same with Concession->data

It may be related to a type difference, maybe in Concession the id is a number, but in concession_id it’s a text ?

Thanks for your reply.

Maybe I’m missing something, but what should I seek for in the log as this is not an input field I’m dealing with, but rather a collection list. What I would like is to display in a collection list based on a “Remises” table (that is linked to “Concessions” table in Supabase) an information located within the “Concessions” table.

And what is surprising, is that when displaying only the id it’s working (once again, I would like to display the name of structures and not their id’s).

It’s really the lookup that is not working, although there is a fk between “Remises” and “Concessions” table

Please show us now what contains the Concessions->data too, to check why lookup can’t find the item

It could happen if you have a filter or pagination on your collection and all the items are not loaded for exemple, lookup will search only on the available data

I checked if there was a blocking filter on the collection, but the only one is regarding the variable “search Concession” which is related to a search bar to look for “Concession” in the dedicated page (and enabled ignore when empty), so I don’t think that it has a impact on it.

See below the Concession data :
Capture d'écran 2024-05-14 165315

Thanks in advance