node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

row.delete() not working on data from google forms

Open physk opened this issue 4 years ago • 1 comments

I seem to be having an issue with row.delete();

here is my code

    let temp = row;
    if (temp['Last Live (GMT)']) {
      if (temp.Status === 'Offline') {
        const lastLive = moment.tz(row['Last Live (GMT)'], config.DATE_FORMAT, config.TIMEZONE);
        const currentLiveSub = moment().subtract(config.STREAM_EXPIRE_SECONDS, 'seconds');
        console.log(`${temp.Link} will expire in ${parseFloat(lastLive.format('X')) - parseFloat(currentLiveSub.format('X'))} Seconds`);
        if (lastLive.isBefore(currentLiveSub)) {
          const prevStreamsSheet = await getSheetTab(
            await serviceAccount(),
            config.PREV_STREAMS_SHEET_ID,
            config.PREV_STREAMS_TAB_NAME,
          );

          console.log(`expire row ${temp.Link}`);
          console.log('add to PreviousSheet');
          await prevStreamsSheet.addRow(temp);
          console.log('delete row from main sheet');
          await temp.delete();
          return;
        }
      }
    }

and i am getting this error:

unhandled fatal error Error: Google API error - [400] Invalid requests[0].deleteRange: Cannot cut from form data. Use copy instead.
    at createError (F:\Development\stream-list-updater-ts\node_modules\axios\lib\core\createError.js:16:15)
    at settle (F:\Development\stream-list-updater-ts\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (F:\Development\stream-list-updater-ts\node_modules\axios\lib\adapters\http.js:236:11)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:482:12)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

physk avatar Sep 19 '20 23:09 physk

It looks like this is because your sheet is linked to a google form. https://support.google.com/docs/thread/12158043?hl=en I think there may still be a way to delete a row, but apparently it's not compatible with how the current row.delete is implemented.

I'd have to do a bit of digging to see what is allowed.

theoephraim avatar Nov 30 '20 18:11 theoephraim