Dragonseel
Dragonseel

Reputation: 147

Use Google Sheets API to conditionally update a subset of data

I have a desktop application that is used to edit a table of data. Each row tracks it's most recent change via a timestamp. Also, there is a Google Spreadsheet that contains that table of data and other people directly use that in the browser to edit the data. On the spreadsheet runs an onEdit script which updates the last-changed timestamp per row.

The desktop app now uses the Google Spreadsheet API to download the sheet and merge the data into the local data by only using rows with a newer timestamp, and this works fine.

I want to add the option to let the desktop app write it's data automatically to the Google Spreadsheet, but to not overwrite all rows, but only those who have an older timestamp.

I have a working version which overwrites all data in the Spreadsheet using the spreadsheets.values.update API, but I don't see how to add a condition to which rows are actually written.

Ideally, the solution would avoid downloading the data, merging it locally and then overwriting the Spreadsheet completely as the data can get quite big and that process would take a long time and would need to limit access to the Spreadsheet while updating in order to not lose changes.

Upvotes: 0

Views: 822

Answers (1)

alberto vielma
alberto vielma

Reputation: 2342

Sorry, but it is not possible to do what you are intending to do. You would have to do a workaround like for example checking if the timestamps are the same before updating the Spreadsheet.

Docs

For more info check these docs:

Upvotes: 1

Related Questions