如何onFormSubmit(),两个单独的Google源电子表格? [英] how to onFormSubmit(), two separate google source spreadsheets?
问题描述
我有两个Google单独的表单,分别向两个单独的电子表格提交新的客户数据.如何在一个应用程序脚本编辑器中的两个单独的电子表格源上使用onFormSubmit()?非常感谢大家:D
I have two google separate forms that submit new client data to two separate spreadsheets. How would I use the onFormSubmit() on two separate spreadsheet sources in one app script editor? thank you all very much :D
如果得到一张纸,它将如何实施两张或更多纸? 我想我得到SpreadsheetApp.getSheetByName('xyz'); 我有点不确定活动表是什么还是被激活了,我认为这是您当前在开发应用程序脚本所源自的电子表格中的工作表.我可能会缺少其他一些基本概念
if this is getting one sheet how could it implement two or more? i think i get SpreadsheetApp.getSheetByName('xyz'); and im a little unsure exactly what an active sheet is or activated I think it is the sheet you're currently on in the spreadsheet the dev app script is being derived from. I might be missing some other basic concepts
function onFormSubmit(){
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sht = ss.getSheetByName('New Client Submission Form (Phone)'&&'New Client Submission Form (Emailed)')
var activeRng = sht.getRange("A2:K2")
var values = activeRng.getValues()
var height = values.length
var width = values[0].length
var ss_dest = SpreadsheetApp.openById('1wgzUSXFNLFQz6tv42Cp_o94qRPAB9IkZnKP5tGL003o')
var sht_dest = ss_dest.getSheetByName('Estimate Compiler')
var destRange = sht_dest.getRange(2,1,height,width)
destRange.setValues(values)
}
此功能确实按预期运行,我只是不知道如何实现两个或更多
this function does exatly as expected I just don't know how to implement two or more yet
推荐答案
function onFormSubmit(e) {
var formObj={LinkedSheet1:FormName1,LinkedSheet2:FormName2};//you provide this from a knowledge of the connection between the form and linked sheet
var form=formObj[e.range.getSheet().getName()];//this returns the form for each sheet
switch (form) {
case 'FormName1':
//code for FormName1
break;
case 'FormName2':
//code for FormName2
break;
}
}
这篇关于如何onFormSubmit(),两个单独的Google源电子表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!