提问人:Eric Mariasis 提问时间:11/16/2023 最后编辑:TheMasterEric Mariasis 更新时间:11/17/2023 访问量:30
Google 表格按钮在桌面上调用关联的应用脚本,但在 Google 表格应用中不调用
Google Sheets Button calls associated app script on desktop but not in Google Sheets app
问:
编辑1:
根据下面标记为已解决的答案,以下是导致其工作的最终添加功能。请注意,我从未让实际按钮在 Sheets 移动应用程序上工作,但复选框作为一种解决方法可以解决问题。
function onEditTrigger(e) {
if (e.range.getSheet().getName() != "Invoice Template" || e.range.columnStart != 9 || e.range.rowStart != 5 || e.value != "TRUE") return;
e.range.setValue("FALSE");
CreateInvoice();
}
function createOnEditTrigger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ScriptApp.newTrigger('onEditTrigger')
.forSpreadsheet(ss)
.onEdit()
.create();
}
结束编辑 1
我有一个 Google 表格,它有一个按钮和一个关联的复选框,启用后,该按钮会调用一个应用程序脚本,该脚本会更改其他一些单元格的值。在桌面 Google 表格上一切正常,但在移动应用程序上,似乎无论我尝试什么,都无法按下按钮。我尝试了一种建议的解决方案,即使用 onEdit 函数作为可安装的触发器而不是简单的触发器,但这似乎没有区别。是否有解决方案,或者 Google 表格应用不支持应用脚本按钮?
下面是我拥有的代码,包括可在桌面上运行的可安装触发器。
function CreateInvoice()
{
//DEFINE ALL ACTIVE SHEETS
var ss = SpreadsheetApp.getActiveSpreadsheet();
//DEFINE MENU SHEET
var invoiceSheet = ss.getSheetByName("Invoice Template");
var customerSheet = ss.getSheetByName("Client Info");
var settingSheet = ss.getSheetByName("Invoice Number Settings");
var printSheet = ss.getSheetByName("Inv Print Copy");
var invoiceLogSheet = ss.getSheetByName("Invoice Log");
//GET VALUES
var customer = invoiceSheet.getRange(4,2).getValue();
var srvc_date = invoiceSheet.getRange(3,6).getValue();
var inv_number = invoiceSheet.getRange(4,6).getValue();
var po_number = invoiceSheet.getRange(5,6).getValue();
var type_1 = invoiceSheet.getRange(8,1).getValue();
var type_2 = invoiceSheet.getRange(9,1).getValue();
var type_3 = invoiceSheet.getRange(10,1).getValue();
var type_4 = invoiceSheet.getRange(11,1).getValue();
var type_5 = invoiceSheet.getRange(12,1).getValue();
var type_6 = invoiceSheet.getRange(13,1).getValue();
var type_7 = invoiceSheet.getRange(14,1).getValue();
var type_8 = invoiceSheet.getRange(15,1).getValue();
var type_9 = invoiceSheet.getRange(16,1).getValue();
var type_10 = invoiceSheet.getRange(17,1).getValue();
var type_11 = invoiceSheet.getRange(18,1).getValue();
var type_12 = invoiceSheet.getRange(19,1).getValue();
var item_description_1 = invoiceSheet.getRange(8,2).getValue();
var item_description_2 = invoiceSheet.getRange(9,2).getValue();
var item_description_3 = invoiceSheet.getRange(10,2).getValue();
var item_description_4 = invoiceSheet.getRange(11,2).getValue();
var item_description_5 = invoiceSheet.getRange(12,2).getValue();
var item_description_6 = invoiceSheet.getRange(13,2).getValue();
var item_description_7 = invoiceSheet.getRange(14,2).getValue();
var item_description_8 = invoiceSheet.getRange(15,2).getValue();
var item_description_9 = invoiceSheet.getRange(16,2).getValue();
var item_description_10 = invoiceSheet.getRange(17,2).getValue();
var item_description_11 = invoiceSheet.getRange(18,2).getValue();
var item_description_12 = invoiceSheet.getRange(19,2).getValue();
var work_description_1= invoiceSheet.getRange(8,4).getValue();
var work_description_2= invoiceSheet.getRange(9,4).getValue();
var work_description_3= invoiceSheet.getRange(10,4).getValue();
var work_description_4= invoiceSheet.getRange(11,4).getValue();
var work_description_5= invoiceSheet.getRange(12,4).getValue();
var work_description_6= invoiceSheet.getRange(13,4).getValue();
var work_description_7= invoiceSheet.getRange(14,4).getValue();
var work_description_8= invoiceSheet.getRange(15,4).getValue();
var work_description_9= invoiceSheet.getRange(16,4).getValue();
var work_description_10= invoiceSheet.getRange(17,4).getValue();
var work_description_11= invoiceSheet.getRange(18,4).getValue();
var work_description_12= invoiceSheet.getRange(19,4).getValue();
var price_1 = invoiceSheet.getRange(8,7).getValue();
var price_2 = invoiceSheet.getRange(9,7).getValue();
var price_3 = invoiceSheet.getRange(10,7).getValue();
var price_4 = invoiceSheet.getRange(11,7).getValue();
var price_5 = invoiceSheet.getRange(12,7).getValue();
var price_6 = invoiceSheet.getRange(13,7).getValue();
var price_7 = invoiceSheet.getRange(14,7).getValue();
var price_8 = invoiceSheet.getRange(15,7).getValue();
var price_9 = invoiceSheet.getRange(16,7).getValue();
var price_10 = invoiceSheet.getRange(17,7).getValue();
var price_11 = invoiceSheet.getRange(18,7).getValue();
var price_12 = invoiceSheet.getRange(19,7).getValue();
var inv_number = settingSheet.getRange(3,2).getValue();
var next_invoice_number = inv_number + 1;
settingSheet.getRange(3,2).setValue(next_invoice_number);
var total_price = invoiceSheet.getRange(20,7).getValue();
var remark = invoiceSheet.getRange(21,1).getValue();
//SET VALUES TO NOTHING
printSheet.getRange(4,2).setValue("");
printSheet.getRange(3,6).setValue("");
printSheet.getRange(4,6).setValue("");
printSheet.getRange(5,6).setValue("");
printSheet.getRange(8,1).setValue("");
printSheet.getRange(9,1).setValue("");
printSheet.getRange(10,1).setValue("");
printSheet.getRange(11,1).setValue("");
printSheet.getRange(12,1).setValue("");
printSheet.getRange(13,1).setValue("");
printSheet.getRange(14,1).setValue("");
printSheet.getRange(15,1).setValue("");
printSheet.getRange(16,1).setValue("");
printSheet.getRange(17,1).setValue("");
printSheet.getRange(18,1).setValue("");
printSheet.getRange(19,1).setValue("");
printSheet.getRange(8,2).setValue("");
printSheet.getRange(9,2).setValue("");
printSheet.getRange(10,2).setValue("");
printSheet.getRange(11,2).setValue("");
printSheet.getRange(12,2).setValue("");
printSheet.getRange(13,2).setValue("");
printSheet.getRange(14,2).setValue("");
printSheet.getRange(15,2).setValue("");
printSheet.getRange(16,2).setValue("");
printSheet.getRange(17,2).setValue("");
printSheet.getRange(18,2).setValue("");
printSheet.getRange(19,2).setValue("");
printSheet.getRange(8,4).setValue("");
printSheet.getRange(9,4).setValue("");
printSheet.getRange(10,4).setValue("");
printSheet.getRange(11,4).setValue("");
printSheet.getRange(12,4).setValue("");
printSheet.getRange(13,4).setValue("");
printSheet.getRange(15,4).setValue("");
printSheet.getRange(16,4).setValue("");
printSheet.getRange(17,4).setValue("");
printSheet.getRange(18,4).setValue("");
printSheet.getRange(19,4).setValue("");
printSheet.getRange(8,7).setValue("");
printSheet.getRange(9,7).setValue("");
printSheet.getRange(10,7).setValue("");
printSheet.getRange(11,7).setValue("");
printSheet.getRange(12,7).setValue("");
printSheet.getRange(13,7).setValue("");
printSheet.getRange(14,7).setValue("");
printSheet.getRange(15,7).setValue("");
printSheet.getRange(16,7).setValue("");
printSheet.getRange(17,7).setValue("");
printSheet.getRange(18,7).setValue("");
printSheet.getRange(19,7).setValue("");
printSheet.getRange(20,7).setValue("");
printSheet.getRange(21,1).setValue("");
// SET VALUES ON INVOICE
printSheet.getRange('F3').setValue(srvc_date).setFontFamily('Calibri').setFontSize(14).setFontColor("#3e01b84").setFontStyle('bold');
printSheet.getRange('B4').setValue(customer).setFontFamily('Calibri').setFontSize(14).setFontColor("#3e01b84").setFontStyle('bold');
printSheet.getRange('F4').setValue(inv_number).setFontFamily('Calibri').setFontSize(14).setFontColor("#3e01b84").setFontStyle('bold');
printSheet.getRange('F5').setValue(po_number).setFontFamily('Calibri').setFontSize(12).setFontColor("3e01b84");
printSheet.getRange('A8').setValue(type_1).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A9').setValue(type_2).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A10').setValue(type_3).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A11').setValue(type_4).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A12').setValue(type_5).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A13').setValue(type_6).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A14').setValue(type_7).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A15').setValue(type_8).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A16').setValue(type_9).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A17').setValue(type_10).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A18').setValue(type_11).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('A19').setValue(type_12).setFontFamily('Calibri').setFontSize(9).setFontColor("3e01b84");
printSheet.getRange('B8').setValue(item_description_1).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B9').setValue(item_description_2).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B10').setValue(item_description_3).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B11').setValue(item_description_4).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B12').setValue(item_description_5).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B13').setValue(item_description_6).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B14').setValue(item_description_7).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B15').setValue(item_description_8).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B16').setValue(item_description_9).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B17').setValue(item_description_10).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B18').setValue(item_description_11).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('B19').setValue(item_description_12).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D8').setValue(work_description_1).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D9').setValue(work_description_2).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D10').setValue(work_description_3).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D11').setValue(work_description_4).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D12').setValue(work_description_5).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D13').setValue(work_description_6).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D14').setValue(work_description_7).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D15').setValue(work_description_8).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D16').setValue(work_description_9).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D17').setValue(work_description_10).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D18').setValue(work_description_11).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('D19').setValue(work_description_12).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G8').setValue(price_1).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G9').setValue(price_2).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G10').setValue(price_3).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G11').setValue(price_4).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G12').setValue(price_5).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G13').setValue(price_6).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G14').setValue(price_7).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G15').setValue(price_8).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G16').setValue(price_9).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G17').setValue(price_10).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G18').setValue(price_11).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G19').setValue(price_12).setFontFamily('Calibri').setFontSize(11).setFontColor("3e01b84");
printSheet.getRange('G20').setValue(total_price).setFontFamily('Calibri').setFontSize(12).setFontColor("3e01b84").setFontStyle('bold');
printSheet.getRange('A21').setValue(remark).setFontFamily('Calibri').setFontSize(10).setFontColor("3e01b84");
//GET LAST ROW OF INVOICE LOG SHEET
var nextRowInvoice = invoiceLogSheet.getLastRow() + 1;
//POPULATE INVOICE LOG
invoiceLogSheet.getRange(nextRowInvoice, 1).setValue(srvc_date);
invoiceLogSheet.getRange(nextRowInvoice, 2).setValue(inv_number);
invoiceLogSheet.getRange(nextRowInvoice, 3).setValue(po_number);
invoiceLogSheet.getRange(nextRowInvoice, 4).setValue(customer);
invoiceLogSheet.getRange(nextRowInvoice, 5).setValue(total_price);
invoiceLogSheet.getRange(nextRowInvoice, 6).setValue(remark);
invoiceLogSheet.getRange(nextRowInvoice, 7).setValue(type_1);
invoiceLogSheet.getRange(nextRowInvoice, 8).setValue(item_description_1);
invoiceLogSheet.getRange(nextRowInvoice, 9).setValue(work_description_1);
invoiceLogSheet.getRange(nextRowInvoice, 10).setValue(price_1);
invoiceLogSheet.getRange(nextRowInvoice, 11).setValue(type_2);
invoiceLogSheet.getRange(nextRowInvoice, 12).setValue(item_description_2);
invoiceLogSheet.getRange(nextRowInvoice, 13).setValue(work_description_2);
invoiceLogSheet.getRange(nextRowInvoice, 14).setValue(price_2);
invoiceLogSheet.getRange(nextRowInvoice, 15).setValue(type_3);
invoiceLogSheet.getRange(nextRowInvoice, 16).setValue(item_description_3);
invoiceLogSheet.getRange(nextRowInvoice, 17).setValue(work_description_3);
invoiceLogSheet.getRange(nextRowInvoice, 18).setValue(price_3);
invoiceLogSheet.getRange(nextRowInvoice, 19).setValue(type_4);
invoiceLogSheet.getRange(nextRowInvoice, 20).setValue(item_description_4);
invoiceLogSheet.getRange(nextRowInvoice, 21).setValue(work_description_4);
invoiceLogSheet.getRange(nextRowInvoice, 22).setValue(price_4);
invoiceLogSheet.getRange(nextRowInvoice, 23).setValue(type_5);
invoiceLogSheet.getRange(nextRowInvoice, 24).setValue(item_description_5);
invoiceLogSheet.getRange(nextRowInvoice, 25).setValue(work_description_5);
invoiceLogSheet.getRange(nextRowInvoice, 26).setValue(price_5);
invoiceLogSheet.getRange(nextRowInvoice, 27).setValue(type_6);
invoiceLogSheet.getRange(nextRowInvoice, 28).setValue(item_description_6);
invoiceLogSheet.getRange(nextRowInvoice, 29).setValue(work_description_6);
invoiceLogSheet.getRange(nextRowInvoice, 30).setValue(price_6);
invoiceLogSheet.getRange(nextRowInvoice, 31).setValue(type_7);
invoiceLogSheet.getRange(nextRowInvoice, 32).setValue(item_description_7);
invoiceLogSheet.getRange(nextRowInvoice, 33).setValue(work_description_7);
invoiceLogSheet.getRange(nextRowInvoice, 34).setValue(price_7);
invoiceLogSheet.getRange(nextRowInvoice, 35).setValue(type_8);
invoiceLogSheet.getRange(nextRowInvoice, 36).setValue(item_description_8);
invoiceLogSheet.getRange(nextRowInvoice, 37).setValue(work_description_8);
invoiceLogSheet.getRange(nextRowInvoice, 38).setValue(price_8);
invoiceLogSheet.getRange(nextRowInvoice, 39).setValue(type_9);
invoiceLogSheet.getRange(nextRowInvoice, 40).setValue(item_description_9);
invoiceLogSheet.getRange(nextRowInvoice, 41).setValue(work_description_9);
invoiceLogSheet.getRange(nextRowInvoice, 42).setValue(price_9);
invoiceLogSheet.getRange(nextRowInvoice, 43).setValue(type_10);
invoiceLogSheet.getRange(nextRowInvoice, 44).setValue(item_description_10);
invoiceLogSheet.getRange(nextRowInvoice, 45).setValue(work_description_10);
invoiceLogSheet.getRange(nextRowInvoice, 46).setValue(price_10);
invoiceLogSheet.getRange(nextRowInvoice, 47).setValue(type_11);
invoiceLogSheet.getRange(nextRowInvoice, 48).setValue(item_description_11);
invoiceLogSheet.getRange(nextRowInvoice, 49).setValue(work_description_11);
invoiceLogSheet.getRange(nextRowInvoice, 50).setValue(price_11);
invoiceLogSheet.getRange(nextRowInvoice, 51).setValue(type_12);
invoiceLogSheet.getRange(nextRowInvoice, 52).setValue(item_description_12);
invoiceLogSheet.getRange(nextRowInvoice, 53).setValue(work_description_12);
invoiceLogSheet.getRange(nextRowInvoice, 54).setValue(price_12);
//DEFINE ALL ACTIVE SHEETS
var ss = SpreadsheetApp.getActiveSpreadsheet();
//DEFINE INVOICE SHEET
var invoiceSheet = ss.getSheetByName("Invoice Template");
//SET VALUES TO NOTHING
invoiceSheet.getRange(4,2).setValue("");
invoiceSheet.getRange(5,6).setValue("");
invoiceSheet.getRange(8,1).setValue("");
invoiceSheet.getRange(9,1).setValue("");
invoiceSheet.getRange(10,1).setValue("");
invoiceSheet.getRange(11,1).setValue("");
invoiceSheet.getRange(12,1).setValue("");
invoiceSheet.getRange(13,1).setValue("");
invoiceSheet.getRange(14,1).setValue("");
invoiceSheet.getRange(15,1).setValue("");
invoiceSheet.getRange(16,1).setValue("");
invoiceSheet.getRange(17,1).setValue("");
invoiceSheet.getRange(18,1).setValue("");
invoiceSheet.getRange(19,1).setValue("");
invoiceSheet.getRange(8,2).setValue("");
invoiceSheet.getRange(9,2).setValue("");
invoiceSheet.getRange(10,2).setValue("");
invoiceSheet.getRange(11,2).setValue("");
invoiceSheet.getRange(12,2).setValue("");
invoiceSheet.getRange(13,2).setValue("");
invoiceSheet.getRange(14,2).setValue("");
invoiceSheet.getRange(15,2).setValue("");
invoiceSheet.getRange(16,2).setValue("");
invoiceSheet.getRange(17,2).setValue("");
invoiceSheet.getRange(18,2).setValue("");
invoiceSheet.getRange(19,2).setValue("");
invoiceSheet.getRange(8,4).setValue("");
invoiceSheet.getRange(9,4).setValue("");
invoiceSheet.getRange(10,4).setValue("");
invoiceSheet.getRange(11,4).setValue("");
invoiceSheet.getRange(12,4).setValue("");
invoiceSheet.getRange(13,4).setValue("");
invoiceSheet.getRange(14,4).setValue("");
invoiceSheet.getRange(15,4).setValue("");
invoiceSheet.getRange(16,4).setValue("");
invoiceSheet.getRange(17,4).setValue("");
invoiceSheet.getRange(18,4).setValue("");
invoiceSheet.getRange(19,4).setValue("");
invoiceSheet.getRange(8,7).setValue("");
invoiceSheet.getRange(9,7).setValue("");
invoiceSheet.getRange(10,7).setValue("");
invoiceSheet.getRange(11,7).setValue("");
invoiceSheet.getRange(12,7).setValue("");
invoiceSheet.getRange(13,7).setValue("");
invoiceSheet.getRange(14,7).setValue("");
invoiceSheet.getRange(15,7).setValue("");
invoiceSheet.getRange(16,7).setValue("");
invoiceSheet.getRange(17,7).setValue("");
invoiceSheet.getRange(18,7).setValue("");
invoiceSheet.getRange(19,7).setValue("");
invoiceSheet.getRange(21,1).setValue("");
var wkbk = SpreadsheetApp.getActiveSpreadsheet()
var spid = wkbk.getId();
var file = DriveApp.getFileById(spid)
var destinationFolder = DriveApp.getFolderById("1MZQmtTvxNPPj8jHpPYBqsdEwHKJySAaZ");
var copyFile = file.makeCopy(wkbk.getName(), destinationFolder);
var tempWkBk = SpreadsheetApp.openById(copyFile.getId())
var sheets = tempWkBk.getSheets();
var totalSheets = tempWkBk.getNumSheets();
var theDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'MMM dd, yyyy')
for (var i = 0; i <= totalSheets-1; i++) {
var sheet = sheets[i]
var sheetName = sheet.getSheetName();
Logger.log(sheetName)
if(sheetName != "Inv Print Copy"){
tempWkBk.deleteSheet(sheet)
}
}
var blobpdf = tempWkBk.getAs('application/pdf')
destinationFolder.createFile(blobpdf).setName("Inv" + " " + inv_number
+ " " + customer +" "+ theDate);
destinationFolder.removeFile(copyFile)
}
function onEditTrigger(e) {
var activeCell = e.range;
var reference = activeCell.getA1Notation();
var sheetName2 = activeCell.getSheet().getName();
var activeValue = activeCell.getValue();
if(reference == 'I5' && sheetName2 == "Invoice Template" && activeValue == true) {
createInvoice();
activeCell.setValue(false);
}
}
function createOnEditTrigger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ScriptApp.newTrigger('onEditTrigger')
.forSpreadsheet(ss)
.onEdit()
.create();
}
/*
function onEdit() {
let activeCell = SpreadsheetApp.getActiveSpreadsheet().getActiveCell()
let reference = activeCell.getA1Notation()
let sheetName2 = activeCell.getSheet().getName()
let activeValue = activeCell.getValue()
if(reference == "I5" && sheetName2 == "Invoice Template" && activeValue == true) {
createInvoice_toupdate();
//createInvoice();
activeCell.setValue(false)
}
}
*/
一些资源建议为我所做的 onEdit 创建一个可安装的触发器,但这似乎没有区别。根据我所研究的内容,也许这只能解决在移动浏览器上工作的问题,而不是在 Google 表格应用程序中工作的问题。在移动设备上使用此功能的唯一方法可能是在移动浏览器上作为桌面打开,但我不确定是否是这种情况。
答:
0赞
Cooper
11/16/2023
#1
我认为这样的事情会起作用:
function onEditTrigger(e) {
if (e.range.getSheet().getName() != "Invoice Template" || e.range.columnStart != "checkbox col" || e.range.rowStart != "checkbox row" || e.value != "TRUE") return;
e.range.setValue("FALSE");
createInvoice();
}
您需要将注释替换为复选框行号和列号,并将其用作按钮。
评论
0赞
Eric Mariasis
11/16/2023
非常感谢,这种方法有效!在移动应用程序中无法按下按钮有点臭,但选中的复选框可以解决问题。
评论
but that didn't seem to make a difference.
console.log