Adding items to a Google Forms list from a spreadsheet range -
i struggling past last line in code appreciated:
the error getting "array empty: values (line 16, file "code")". have double checked item id, spreadsheet id , there data pick within correct range. pointers or insights...?
function getfleet() { var ssdefects = spreadsheetapp.getactivespreadsheet().getsheets()[0]; var rngfleet = ssdefects.getdatarange(); var values = rngfleet.getvalues(); var fleetlist = []; //use column 0 , ignore row 1 (headers) (var = 1; <= values.length; i++) { var v = values[i] && values[i][0]; v && values.push(v) } // form id & list id var defectsform = formapp.openbyid('<form key id>'); defectsform.getitembyid(794194842).aslistitem().setchoicevalues(fleetlist); };
nothing pushed array fleetlist. coding in loop faulty. assuming want push first column (not including header), try , see if works
function getfleet() { var values = spreadsheetapp.getactivespreadsheet() .getsheets()[0].getdatarange() .getvalues(); var fleetlist = []; //use column 0 , ignore row 1 (headers) (var = 1, len = values.length; < len; i++) { fleetlist.push(values[i][0]) } // form id & list id var defectsform = formapp.openbyid('<form key id>'); defectsform.getitembyid(794194842) .aslistitem() .setchoicevalues(fleetlist); };
Comments
Post a Comment