Help

Get the value of a lookup field

Topic Labels: API
Solved
Jump to Solution
404 3
cancel
Showing results for 
Search instead for 
Did you mean: 
andy_m
5 - Automation Enthusiast
5 - Automation Enthusiast

Just to be clear. When I add a lookup field to a table, that field is not accessible direct through `

getCellValue`, correct? I still have to get the id of the corresponding Linked Record field, and do another lookup to get the value of the field that matches my Lookup field. Correct?
 
Just want to make sure I'm not crazy, because it sure seems like extra work for what could be available directly in the table itself. 



1 Solution

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

Doing a 'getCellValue' on a lookup field gives me the value of the lookup field in an array:

Screenshot 2024-04-03 at 8.04.52 AM.png
Screenshot 2024-04-03 at 8.04.55 AM.png

See Solution in Thread

3 Replies 3
AlliAlosa
10 - Mercury
10 - Mercury

If you’re talking about scripting, this depends on the type of data you’re looking up, and where you’re running the code from.

Regardless of the data type, I think getCellValueAsString() should work to return the value as a string. I’m on my phone so haven’t tested, but I believe that’s the case.

A bit of annoying nuance - if you’re looking up a linked record field, getCellValue() will behave differently in a script extension vs. an automation step. In the extension it should return an array of objects containing the id and name of each linked record in the lookup field. In an automation step, I believe it returns an array of strings containing only the ids.

TheTimeSavingCo
18 - Pluto
18 - Pluto

Doing a 'getCellValue' on a lookup field gives me the value of the lookup field in an array:

Screenshot 2024-04-03 at 8.04.52 AM.png
Screenshot 2024-04-03 at 8.04.55 AM.png

andy_m
5 - Automation Enthusiast
5 - Automation Enthusiast

wow. 😲
I've just been calling the field by the field name. However when I tested using the field's actual ID, I got the array as you guys pointed out. Then I tried using the field name as displayed and got the array. 
Example: I have field called `user` in table A. In table B I create a Linked Record that displays `user` in table B. I was looking up the field as `user`. However it's actually `user (from linked_record)`. Never would have figured that out. 
thanks a ton, this really helps me out a lot. I've been making so many unnecessary queries today to get around what I thought was a limitation.

fwiw, I'm doing pretty much everything through external node scripts using the AirTable node library.