Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 谷歌电子表格脚本函数调用_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 谷歌电子表格脚本函数调用

Google apps script 谷歌电子表格脚本函数调用,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我正在谷歌文档中使用一个表单。我有一个脚本,用于为每个条目自动增加一列,还有一个函数用于检查当前条目是否具有类似的条目。代码如下所示 函数onFormSubmit(e){ var sheet=SpreadsheetApp.getActiveSheet(); var row=SpreadsheetApp.getActiveSheet().getLastRow(); sheet.getRange(第7行).setValue('sn'+(第1行)); } 函数RemovedDuplicates(){

我正在谷歌文档中使用一个表单。我有一个脚本,用于为每个条目自动增加一列,还有一个函数用于检查当前条目是否具有类似的条目。代码如下所示

函数onFormSubmit(e){
var sheet=SpreadsheetApp.getActiveSheet();
var row=SpreadsheetApp.getActiveSheet().getLastRow();
sheet.getRange(第7行).setValue('sn'+(第1行));
}
函数RemovedDuplicates(){
var sheet=SpreadsheetApp.getActiveSheet();
var data=sheet.getDataRange().getValues();
var newData=newarray();
对于(数据中的i){
var行=数据[i];
var duplicate=false;
对于(新数据中的j){
if(行[1]==newData[j][1]&行[2]==newData[j][2]){
重复=正确;
}
}
如果(!重复){
newData.push(行);
formSubmitReply();
}
}
sheet.clearContents();
sheet.getRange(1,1,newData.length,newData[0].length).setValues(newData);
}
如您所见,第一个函数用于自动增加列,第二个函数用于检查重复条目。我可以用不同的方式触发它们,但我想做的是,在第二个函数中调用第一个函数,这样当我触发提交表单的第二个函数时,它会自动运行其中的第一个函数。我该怎么做


注意:像
onFormSubmit()
这样的简单调用不起作用。

将要从多个位置运行的代码计算出来。而不是这样做:

function eventHandler(e) {
   // code to increase column
}

function otherFunction() {
   // code to remove duplicates
   eventHandler(e);   // won't work, e is undefined!
}
您可以这样做:

function tinyHelperFunction() {
  // code to increase column
}

function eventHandler(e) {
  tinyHelperFunction();
  // other stuff, maybe
}

function otherFunction() {
  // code to remove duplicates
  tinyHelperFunction();
}