Delete All Rows in a Table usng Coda API

144 views Asked by At

The code below, requires row id's, in order for us to delete multiple rows in a Coda table using Gogle App Script.

// Import the CodaAPI library via Resource->Libraries...:
   
    CodaAPI.authenticate('<your API token>');
var body = {
             'rowIds': ['i-aBcDeFgH', 'i-AbCdEfGh'],
    };
   CodaAPI.deleteRows('<doc ID>', '<table ID>', body);
   Logger.log('Deleted 2 rows');

How will I delete rows in a Coda table without the knowledge of row ID’s beforehand ? Or another question is how to get the list of Row ID’s from a table? Thanks!

1

There are 1 answers

0
PCDSandwichMan On

To get row ids you could use:

// Get row ids of all rows in the sheet:
const rowIds = await CodaAPI.getRowIds('<your sheet id>');

As far as using that information to delete your rows. I would need a bit more context regarding your use case to help you out.