在事件处理程序中查找所有值作为参数e

时间:2014-06-27 15:56:55

标签: google-apps-script

我有一个表单,我希望我的eventInfo的所有值都在一个数组上,是否可能?

我有这个:

function doPost(eventInfo) {  

     var submited = eventInfo.values;
       Logger.log(submited);   // undefined
       Logger.log(eventInfo.parameter) //  all Informations

    // Code 
     return app;
    }

我用这个:

Logger.log(EventInfo.parameter);

我有我的控制台:

 {D Machines tank repair=interesting, appId=..., 
 DS Pad ownership=rejected, 
 Alloy output heating system=implemented, 
 Dip Coating Module Leak Detection=implemented, 
 Zirkonium pills=implemented, 
 gm1xs=, lib=..., 
 Theory of Constraints Training=interesting, 
 DSPC Spheric Lens Reuse=interesting, 
 formId=form, token=..., 
 Hardcoat - Connecting Processes=rejected, 
 service=..., 
 Varnish Consumption Reduction=implemented, 
 Water saving in Generator cleaning=interesting}

例如,我有这个: 发电机清洁节水=有趣

我如何自动使用这个因为我想要这个数组?

Array[0][0] = Water saving in Generator cleaning; 
Array[0][1] = interesting;

2 个答案:

答案 0 :(得分:0)

快速search on Google会返回很多结果......

使用onEdit in a spreadsheet的示例:

function onEdit(e) {
  for(var propertyName in e) {
    Logger.log(propertyName + ' = ' + e[propertyName]);
  }
}

enter image description here

答案 1 :(得分:0)

感谢Serge Insas。

你帮我解决了问题。

你的解决方案不适合我:

function onEdit(e) {
  for(var propertyName in e) {
    Logger.log(propertyName + ' = ' + e[propertyName]);
  }
}

我的日志:

[14-06-30 10:11:32:469 CEST] parameter = [object Object]
[14-06-30 10:11:32:469 CEST] contextPath = 
[14-06-30 10:11:32:469 CEST] contentLength = 1278

但是如果你采取这个解决方案:

 for(var propertyName in e.parameter) {
    Logger.log(propertyName + ' = ' + e.parameter[propertyName]);
  }

我的日志:

    [14-06-30 10:11:32:471 CEST] Alloy output heating system = implemented
    [14-06-30 10:11:32:471 CEST] Dip Coating Module Leak Detection = implemented
    [14-06-30 10:11:32:471 CEST] Zirkonium pills = implemented