Skip to main content

I have created a script to delete  a record but it is giving me an error. Here is the code:

 
console.log(`Hello, ${"300 Replens"}!`);
let table = base.getTable("300 Replens")
await table.deleteRecordAsync(input.config()['reckUma1c1NLjQADd']);
 
Here is the log:

CONSOLE.LOG

  1. "Hello, 300 Replens!"

ERROR

TypeError: Invalid arguments passed to table.deleteRecordAsync(recordOrRecordId): • recordOrRecordId → recordOrRecordId should be a Record, not undefined or recordOrRecordId should be a string, not undefined
    at main on line 4

I got the record id after expanding a record and copying it from the google search bar. Why is the log saying undefined?

Thank you

To add to my post. The log says I can use Record or recordid. How is Record specified? THanks.


Use variable-based code style like 

 

let inputConfig = input.config(); // Make sure that input.config() should be called only a single time in a script
let recordId = inputConfig.recordId
// Then use this line with delete function
await table.deleteRecordAsync(recordId);

 

See the attached image as well.

I hope this helps.


That script will not work. The script below is a working deletion script, if you define myRecord as shown in the screenshot below:

 

let inputConfig = input.config();
let recordId = inputConfig.myRecord;
let table = base.getTable("Type Your Table Name Here");
await table.deleteRecordAsync(recordId);

 


That script will not work. The script below is a working deletion script, if you define myRecord as shown in the screenshot below:

 

let inputConfig = input.config();
let recordId = inputConfig.myRecord;
let table = base.getTable("Type Your Table Name Here");
await table.deleteRecordAsync(recordId);

 


Hi ScottWorld, thank you for your response but I'm still getting the same errors see log below. Is recordid specified outside of the script maybe?

ERROR
TypeError: Invalid arguments passed to table.deleteRecordAsync(recordOrRecordId):
• recordOrRecordId →
recordOrRecordId should be a Record, not undefined
or recordOrRecordId should be a string, not undefined

at main on line 4

thanks


Use variable-based code style like 

 

let inputConfig = input.config(); // Make sure that input.config() should be called only a single time in a script
let recordId = inputConfig.recordId
// Then use this line with delete function
await table.deleteRecordAsync(recordId);

 

See the attached image as well.

I hope this helps.


Where does recordid get specified? Thanks.


You can see it getting set in the left margin of my screenshot.

Alternatively, if you’re having difficulty with scripting and you just want an easy, no-code way to delete records, you can always use Make’s Airtable Automations, which come with their own “Delete Record” action.

There is a small learning curve with Make, which is why I created this basic navigation video to help. I also provide the links to a few other Make training resources there as well. 

 

 


Hi ScottWorld, Thanks for the quick response. It's working now and thanks for the links.


Hi ScottWorld, Thanks for the quick response. It's working now and thanks for the links.


You can use input.config() directly, if you have just one input variable

let recordId = input.config().myRecord;

and even use 'oneliner'

await base.getTable('table_name').deleteRecordAsync(input.config().recordId)

 but if you want to understand at least code basics, I would recommend to move step by step ))


Reply