Help

automation : deleting arrays

Topic Labels: Automations
Solved
Jump to Solution
1772 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Jessica_Shin
5 - Automation Enthusiast
5 - Automation Enthusiast

I set up schedule automation to find records under certain condition and delete those records.

however, using script to delete the found records doesn't seem to work.

the script I'm using here is the following:

---------------------------------------------------------

let table = base.getTable("각종주문서수집");
let inputConfig = input.config();id.JPG
let recordId = inputConfig['recordID'];
await table.deleteRecordAsync(recordId);
---------------------------------------------------------

 

when I test, this script kept throwing fail notice showing the 'recordID' of the input variable I made is an array not a record.

How can I change this to scipt to work with array of recordID ? or is there any way that I can select every record ID values instead of 'list of record ID'? I don't get any other options at the 'value' box an I assign the input.

 

1 Solution

Accepted Solutions

Hmm, try replacing that "await" line with:

while (recordId.length > 0) {
    await table.deleteRecordsAsync(recordId.slice(0, 50));
    recordId = recordId.slice(50);
}

"Find Records" has a max return limit of 100 records as well, so you're going to have to factor that in to your automation setup I believe

See Solution in Thread

4 Replies 4

Change 

await table.deleteRecordAsync(recordId);

to

await table.deleteRecordsAsync(recordId);

And that should work fine

Hi Adam, thanks for your solution.

adding 's' to the script seems to work but now I get different error sign :

ERROR

Error: Request exceeds maximum batch size limit of 50 items
    at main on line 4

 

number of items to delete can be from 0 to 500 sometimes.

Please help!

 

Hmm, try replacing that "await" line with:

while (recordId.length > 0) {
    await table.deleteRecordsAsync(recordId.slice(0, 50));
    recordId = recordId.slice(50);
}

"Find Records" has a max return limit of 100 records as well, so you're going to have to factor that in to your automation setup I believe

This worked!!! thank you sooooooo much!😀