I have a google form with an item list for all the employees. I am populating this list from a MySQL table. I am trying to refresh the form with an updated employee list every time the google form is opened. I have an on open event trigger but for some reason the list does not get updated. Please let me know.
function onOpen(){
var form = FormApp.openById('239jelkwpeowppd-3843ikeifd89wered');
var conn = mySQL();
var itemList = getEmpList(conn);
var item = form.getTitle('Approver:');
item.setChoiceValues(itemList);
}
function getEmpList(conn){
var sql = conn.createStatement();
var ds = sql.executeQuery('SELECT empNAME FROM emp');
var columns = ds.getMetaData().getColumnCount();
var list=[];
while (ds.next()) {
var rowString = '';
for (var col = 0; col < columns; col++) {
rowString += ds.getString(col + 1) + '\t';
list.push(rowString);
}
}
return list;
}
function mySQL(){
var dbConn = Jdbc.getConnection("jdbc:mysql://dbURL","user","password");
return dbConn;
}