简体   繁体   中英

Google apps script find the number of items on a form

Is there a way to get a count of items listed on a google form. For instance I create a google sign-up form for a class my form would look something like below.

function getFormItemCnt(){
 var f = FormApp.openById('abcd123kfeofkl-mdsfsd8rferSAFRgdsl')
 var formRs = f.getResponses();
 var fR = fRs[formRs.length-1];
 var iRs = fR.getItemResponses();

   for (var j = 0; j < iRs.length; j++) {
     var iR = iRs[j]; 
     // Is there a way to get the doing something like below
     // var cnt = iR.getItem().getCount();
}

This will give you a dialog with the items index and type.

function myForm()
{
  var myForm=FormApp.getActiveForm();
  var items=myForm.getItems();
  for(var i=0;i<items.length;i++)
  {
    Logger.log('Item[%s].getItemType=%s',i,items[i].getType());
  }
  var ui=HtmlService.createHtmlOutput(Logger.getLog());
  FormApp.getUi().showModelessDialog(ui, 'Items');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM