Re: [Apps-Script] How to compare google form respondents with the respondent on google sheet using google script

33 views
Skip to first unread message
Message has been deleted

Brian Pugh

unread,
Aug 13, 2023, 11:56:28 PM8/13/23
to google-apps-sc...@googlegroups.com
Lim, I made slight but important changes (noted in the screenshot, below). Once I did, the script ran well.


script.jpg

















Brian Pugh, IT/Educational Technologies



Associated Hebrew Schools | Danilack Middle School

p: 416.494.7666, | e: bp...@ahschools.com

w: www.associatedhebrewschools.com

252 Finch Ave W., Toronto, ON M2R 1M9


facebook.png twitter.png instagram.png 


This email is confidential and is intended for the above-named recipient(s) only. If you are not the intended recipient, please delete this email from your system. Any unauthorized use or disclosure of this email is prohibited.




On Sun, Aug 13, 2023 at 9:41 PM lumbanon lim <lumba...@gmail.com> wrote:
Below are the code that i have done and i ran it on the "testing" spreadsheet:
function findMissingAttendees() {
  // Open the Google Form by ID
  var form = FormApp.openById('1KwyCDjFxltlkA_ym9Nrpl-BL6BmVMeZH1-02klUv9Ac')
 
 // Get all responses from the form
  var formResponses = form.getResponses();

  // Get the desired sheet by name
  var sheetName = 'testing';
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
 
  if (!sheet) {
    Browser.msgBox("Sheet named '" + sheetName + "' not found.");
    return;
  }
 
  var attendeeColumnValues = sheet.getRange('C2:C' + sheet.getLastRow()).getValues();
 
  var missingAttendees = [];
 
  // Loop through each attendee and check if they've responded to the form
  attendeeColumnValues.forEach(function(row) {
    var attendeeEmail = row[0];
    var hasResponded = false;
     
    formResponses.forEach(function(response) {
      var responseEmail = response.getRespondentEmail();
      if (responseEmail === attendeeEmail) {
        hasResponded = true;
      }
    });
   
    if (!hasResponded) {
      missingAttendees.push(attendeeEmail);
    }
  });

  // Display the missing attendees
  if (missingAttendees.length > 0) {
    var missingAttendeesString = missingAttendees.join(', ');
    Browser.msgBox('Missing Attendees: ' + missingAttendeesString);
  } else {
    Browser.msgBox('All attendees have responded!');
  }
}

When i clicked "run" it keep showing the "testing sheet name is not found" on the spreadhseet not on the execution log, the execution logs showed execution completed. i have checked the name and gave the permission. 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6c2e73ef-7356-4621-bc86-8960b8474e8fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages