Created
March 8, 2020 03:03
-
-
Save roxberry/2dc14f26339c2dfc32f5713d5f6062b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setReferees() { | |
Logger.log("Starting function"); | |
var ssID = "xxxxx"; | |
var formID = "xxxxx"; | |
var wsData = SpreadsheetApp.openById(ssID).getSheetByName("data"); | |
var refData = wsData.getRange(2, 1, wsData.getMaxRows() - 1).getValues(); | |
var form = FormApp.openById(formID); | |
var items = form.getItems(); | |
var refFieldId = 0; | |
Logger.log("Loop through items"); | |
items.forEach(function(item) { | |
//Logger.log(item.getTitle() + ":" + item.getId()); | |
if (item.getTitle() === "Referee Name") | |
{ | |
refFieldId = item.getId(); | |
} | |
}); | |
Logger.log(refFieldId); | |
//refFieldId = 440230474; | |
var dropDownData = form.getItemById(refFieldId).asListItem(); | |
var refList = []; | |
// convert the array ignoring empty cells | |
for(var i = 0; i < refData.length; i++) | |
if(refData[i][0] != "") | |
refList[i] = refData[i][0]; | |
// populate the drop-down with the array data | |
dropDownData.setChoiceValues(refList); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment