如何检查当前表单提交是否正在编辑响应 [英] How to check if current form submission is editing response

查看:75
本文介绍了如何检查当前表单提交是否正在编辑响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要返回已重新提交的Google表单提交的行号.

I need to return the row number of a Google Form submission that has been resubmited.

我关注了以下所有信息:

I followed all of the information at: Google Forms App Script : How to check if current submission is editing response or a new response, but I get this error for trigger formSubmit:

异常:无法将"15.0"转换为int.

Exception: Cannot convert '15.0' to int.

所以它正确地找到了第15行,并似乎给了我一个数字,但是当我尝试使用该数字时,我一直收到错误消息.

So it is correctly finding the 15th row as edited and appears to be giving me a number, but i keep getting the error when i try to use that number.

我尝试使用+numNumber()进行转换,将行号放入单元格中并手动更改格式,然后使用脚本和公式将其复制到另一个单元格中,但是我仍然继续遇到此错误当formSubmit发生时.您能帮我确定如何解决此错误吗?

I've tried to convert it using +num, Number(), place the row # into a cell and change the format manually, and copy it to another cell using script and formula but I still continue to get this error when formSubmit occurs. Can you help me determine how to fix this error?

function email(e) { 
var sh   = SpreadsheetApp.getActiveSheet();
var ss   = SpreadsheetApp.getActiveSpreadsheet();  
var gid  = sh.getSheetId().toString(); 
var last = ss.getLastRow();
var valueColumnLocation;

for(k=1;k<=ss.getLastColumn();k++) {
  if (sh.getRange(1,k).getValues() == "Select Worksite") {
    var valueColumnLocation = k;
    break;
  }
};


...
if (...){...}

  else{
  var rowrev = e.range.getRow();
  //sh.getRange("rownumberrev").setValue(rowrev);

  PropertiesService.getScriptProperties().setProperty('mykey',rowrev); 

  if (sh.getRange(rowrev,valueColumnLocation,1,1).getValues()=="USA"){
    uploadrev()
    pdfFCrev()
  }

    else{if(sh.getRange(rowrev,valueColumnLocation,1,1).getValues()=="GLOBAL"){
      uploadrev()
      pdfGLrev()           
      }

    } 
  }
}


在原始帖子中添加更多详细信息 Google表单填充的电子表格的列为A-CZ 我正在寻找已编辑的行,然后在该行的特定列中寻找一个值.如果该值==美国,请执行此操作;如果该值== Global,请执行此操作.


Adding more detail to original post The spreadsheet that the google form populates has columns A - CZ I'm looking to find the row that was edited and then look for a value in a specific column of that row. If that value==USA, do this or if value==Global, do that.

因此,在这张照片中,用户重新提交了第15行,并且更改在E列中.我想利用已编辑第15行的知识,我们之前发现"Select Worksite"列#现在位于在Z列中检查值是否在(15,26,1,1)== USA或Global范围内.

So in this picture, row 15 was resubmitted by the user and the change was in column E. I want to use the knowledge that row 15 was edited and we earlier found the column # of "Select Worksite" which now resides in column Z and check if the value in range(15,26,1,1)==USA or Global.

也许这是我没有想到的一种完全不同或更好的方法,但是当我尝试在sh.getRange()中使用e.range值时,出现错误,它无法将15.0转换为int

Maybe there's a completely different or better way to do this that's i'm not thinking of, but when i try to use the e.range value in the sh.getRange() i get the error it cannot convert 15.0 to int.

推荐答案

在我看来,您可以使用以下命令完成整个功能:

Looks to me like you can do the entire function with this:

function email(e) { 
  PropertiesService.getScriptProperties().setProperty('mykey',e.range.getRow()); 
  if(e.namedValues["Select Worksite"]=="USA"){
    uploadrev();
    pdfFCrev();
  }
  if(e.namedValues["Select Worksite"]=="GLOBAL"){
    uploadrev()
    pdfGLrev()           
  }
}

在编写代码时需要阅读文档.

It pays to read the documentation while your writing your code.

在FormSubmit事件对象上

on FormSubmit Event Object

这篇关于如何检查当前表单提交是否正在编辑响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆