Help

Script error linked record

Topic Labels: Automations
Solved
Jump to Solution
804 3
cancel
Showing results for 
Search instead for 
Did you mean: 
uitholland
4 - Data Explorer
4 - Data Explorer

Hi, 

I want to create a new record and link it with the right assets.

Creating the record goes wel, but linking the assets won't work.

I get this error. I am a bit new to airtable, maybe it is a beginner mistake.

Thanks in advance.

Greetings,
Robin

Scherm­afbeelding 2024-10-31 om 20.26.14.png

 

 

 

const inputData = input.config();
const { txt_name, txt_files } = inputData;

// Specify the tables
let postsTable = base.getTable('Social media posts');
let assetsTable = base.getTable('Assets');

// Create a new record in the 'Social media posts' table and capture the ID
let newRecordId = await postsTable.createRecordAsync({
    'Naam': txt_name,
});

// Update the record in 'Assets' where the ID matches txt_files, setting "Social media posts" field to the new record ID
await assetsTable.updateRecordAsync(txt_files, {
    'Social media posts': [{ id: newRecordId }],
});

 

 

 

2 Solutions

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

Could I check that you've set your input variable for the linked record to display as "ID"?
Screenshot 2024-11-01 at 10.11.01 AM.png

The linked records value is also an array, so you'd need to do `txt_files[0]` in your updateRecordAsync

See Solution in Thread

Thanks!  Also just realized that your screenshot actually includes that detail, sorry about missing that

Did the array thing work?

See Solution in Thread

3 Replies 3
TheTimeSavingCo
18 - Pluto
18 - Pluto

Could I check that you've set your input variable for the linked record to display as "ID"?
Screenshot 2024-11-01 at 10.11.01 AM.png

The linked records value is also an array, so you'd need to do `txt_files[0]` in your updateRecordAsync

@TheTimeSavingCo 

Yes, it is...

Scherm­afbeelding 2024-11-01 om 08.51.46.png

Thanks!  Also just realized that your screenshot actually includes that detail, sorry about missing that

Did the array thing work?