Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

How to insert into a Link field when accessing Airtable via SQL

Topic Labels: Integrations
Solved
Jump to Solution
1295 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Ramirez
5 - Automation Enthusiast
5 - Automation Enthusiast

Im using Retool with Sequin to link my airtable database to Retool and im trying to insert into a link field some data but i cant do it like how i would normally insert a field with a sql query

1 Solution

Accepted Solutions
Alexey_Gusev
13 - Mars
13 - Mars

You can't just put some random text to link field.
Usual value of link field is array of objects:

Alexey_Gusev_0-1698469891007.png

When you work with usual Airtable in browser or app, you can paste value or values, separated by comma.
each value is a Name of record to link.
These values should exist in the primary field of a linked table, otherwise it creates a new record with such name (name is a value of a primary field) and empty other fields. If record can't be created, it does nothing.

In script, you usually need to put array of IDs, not a list of strings. Like this.
[ {'id':'rec123Abc456dEF'} , {'id':'rec890qwerTYUI'} ]

to clean cell, you need to pass empty array  [] 

See Solution in Thread

3 Replies 3
Alexey_Gusev
13 - Mars
13 - Mars

You can't just put some random text to link field.
Usual value of link field is array of objects:

Alexey_Gusev_0-1698469891007.png

When you work with usual Airtable in browser or app, you can paste value or values, separated by comma.
each value is a Name of record to link.
These values should exist in the primary field of a linked table, otherwise it creates a new record with such name (name is a value of a primary field) and empty other fields. If record can't be created, it does nothing.

In script, you usually need to put array of IDs, not a list of strings. Like this.
[ {'id':'rec123Abc456dEF'} , {'id':'rec890qwerTYUI'} ]

to clean cell, you need to pass empty array  [] 

Ramirez
5 - Automation Enthusiast
5 - Automation Enthusiast

i ended up with the next insert query: 

INSERT INTO table (linkfield) VALUES ('recipxpYRlJ16okEX')

and it worked, thank you very much.

Great to know. As former MSSQL DBA, I tried to find a way to use T-SQL in Airtable, didn't find an easy way to do it. Then I learned JS basics and found it more convenient for my purposes.