Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

If a response is deleted manually in a Google form, is any flag/notice available to apps-script so that appropriate actions can be scripted for dealing with the corresponding row in the linked sheet? This is desired so that the sheet can be kept in synch with the form responses, or the form response can be re-submitted programmatically from the sheet row, if the response was improperly deleted.

Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
188 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is no delete response event trigger available for both Google Sheets events and Google Forms events.

One workaround that you may do is to create an onOpen() installable trigger in your linked Google Sheets using Apps Script that will check if the Google Forms responses count using Form.getResponses() matches the available responses in your sheet whenever you open the linked Google Sheets.

Sample Apps Script:

function onOpen(e) {
  var form = FormApp.openById('Forms file id here');
  var formResponses = form.getResponses();
  
  var responseSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses 1');
  
  //Get number of responses saved in the sheet (Subtract 1 for the header row);
  var sheetResponses = responseSheet.getLastRow() - 1;
  
  Logger.log(formResponses.length);
  Logger.log(sheetResponses);
  
  if (formResponses.length != sheetResponses){
    
    var ui = SpreadsheetApp.getUi(); 

    var result = ui.alert(
      'Warning',
      'Responses did not match.',
      ui.ButtonSet.OK);

    // Sync responses here
  }

}

Sample Forms Responses: enter image description here

Sample Output: (when you open your linked Google Sheets) enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...