Существует код, над которым мы с бывшим коллегой работали над оптимизацией листа Google. Он использует скрипт Google и HTML для создания пользовательского меню и форму для сбора или вызова данных из строк на листе Google (лист 1). Функционально это работало хорошо с 29.02.2020. Откроется форма, однако данные больше не могут быть извлечены из листа (лист 1) и данные не будут отправлены на тот же лист. Пользовательский пункт меню Пользовательская форма
Код
//The toolbar menu
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [
{name: 'Create New 8D', functionName: 'createNew_'},
{name: 'Update', functionName: 'update_'}
];
spreadsheet.addMenu('8D Menu', menuItems);
}
//Call function pop-up to Create New
function createNew_() {
var html = doGet();
SpreadsheetApp.getUi().showModalDialog(html, 'Create New');
}
//google apps scripts get row by column value
function findInColumn(column, data) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var column = sheet.getRange(column + ":" + column); // like A:A
var values = column.getValues();
var row = 0;
while ( values[row] && values[row][0] != data ) {
row++;
}
if (values[row][0] == data) {
return row+1;
}else {
return -1;
}
}
//Create a Data Entry Form
function doGet() {
var result = HtmlService
.createTemplateFromFile('Form')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
result.setHeight(600);
result.setWidth(800)
return result;
}
//Retrieves data from the return form and fills the spreadsheet
function getValuesFromForm(form){
var customer = form.customer,
scar_id = form.scar_id,
issue_date = form.issue_date,
eight_d_tat = form.eight_d_tat,
problem_statement = form.problem_statement,
leader = form.leader,
sponsor = form.sponsor,
business_root_cause = form.business_root_cause,
impact = form.impact,
occurence = form.occurence,
detection = form.detection,
closed_date = form.closed_date,
d3_due = form.d3_due,
d5_due = form.d5_due,
d7_due = form.d7_due,
d3_sent = form.d3_sent,
d5_sent = form.d5_sent,
d7_sent = form.d7_sent,
cqe = form.cqe,
cust_actions = form.cust_actions,
fab_actions = form.fab_actions,
loc = form.loc,
tech = form.tech,
mrb = form.mrb,
mrb1 = form.mrb1,
auto = form.auto,
sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var lastRow = sheet.getLastRow();
//Import data into the spreadsheet
sheet.getRange(lastRow + 1, 2).setValue(customer);
sheet.getRange(lastRow + 1, 3).setValue(Scar_ID);
sheet.getRange(lastRow + 1, 4).setValue(eight_d_tat);
sheet.getRange(lastRow + 1, 5).setValue(problem_statement);
sheet.getRange(lastRow + 1, 6).setValue(issue_date);
sheet.getRange(lastRow + 1, 7).setValue(closed_date);
sheet.getRange(lastRow + 1, 8).setValue(business_root_cause);
sheet.getRange(lastRow + 1, 9).setValue(d3_due);
sheet.getRange(lastRow + 1, 10).setValue(d5_due);
sheet.getRange(lastRow + 1, 11).setValue(d7_due);
sheet.getRange(lastRow + 1, 12).setValue(d3_sent);
sheet.getRange(lastRow + 1, 13).setValue(d5_sent);
sheet.getRange(lastRow + 1, 14).setValue(d7_sent);
sheet.getRange(lastRow + 1, 15).setValue(cqe);
sheet.getRange(lastRow + 1, 16).setValue(leader);
sheet.getRange(lastRow + 1, 17).setValue(sponsor);
sheet.getRange(lastRow + 1, 18).setValue(cust_actions);
sheet.getRange(lastRow + 1, 19).setValue(fab_actions);
sheet.getRange(lastRow + 1, 20).setValue(loc);
sheet.getRange(lastRow + 1, 21).setValue(tech);
sheet.getRange(lastRow + 1, 22).setValue(mrb);
sheet.getRange(lastRow + 1, 23).setValue(mrb1);
sheet.getRange(lastRow + 1, 24).setValue(auto);
sheet.getRange(lastRow + 1, 27).setValue(impact);
sheet.getRange(lastRow + 1, 28).setValue(occurence);
sheet.getRange(lastRow + 1, 29).setValue(detection);
}
function getValuesFromSheet(form){
var row = findInColumn('A',form.gf_8d_number);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var obj = {};
obj.fieldKey = {};
obj.keyField = {};
obj.values = {};
//mappings
var lf = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
for(x in lf){
obj.fieldKey[lf[x].replace(' ','_').toLowerCase()] = x;
obj.keyField[x] = lf[x].replace(' ','_').toLowerCase();
}
//values
var rowValues = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0];
obj.rowo = rowValues[2];
//obj.kf = [];
for(f in obj.keyField){
var v = rowValues[f];
obj.values[obj.keyField[f]] = v+'';
}
return obj;
}
function getColumnMappings(form){
var row = findInColumn('A',form.gf_8d_number);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
//var obj = {};
//obj.sheet = sheet;
//obj.test = form.gf_8d_number;
//obj.rowo = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0][1];
//sheet.getRange(row, column).setValues(values)
//obj.customer = form.customer;
//obj.firstrow = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var fields = {};
var lf = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
for(x in lf){
fields[lf[x].replace(' ','_').toLowerCase()] = x;
}
//for(sheet.getRange(1, 1, 1, sheet.getLastColumn())
return fields;
}