【发布时间】:2018-09-02 18:36:34
【问题描述】:
每次下新订单时,我都会使用 Zapier 更新 Google 表格,并在其中创建新行。
例如
COL A | COL B
-------------
Sku No |
我希望 COL B 在每次创建行时都有时间戳。
我试过这个脚本,但它只适用于编辑,也就是说,如果单元格是手动编辑的。
function timestamp() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Order Details" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 4 ) { //checks the column
var nextCell = r.offset(0, -2);
if( nextCell.getValue() === '' ) //is empty?
nextCell.setValue(new Date());
}
}
}
我见过一些我现在无法参考的示例,其中单元格中使用的唯一关键字在与脚本一起使用时会插入静态时间戳。
如何做到这一点?任何帮助表示赞赏。
【问题讨论】:
-
最简单的解决方案是让 Zapier 也写下时间,是吗?还是 Zapier 激活了一些 webapp 链接?您是否检查过 Zapier 的更新是否触发了
on change事件?
标签: google-apps-script google-sheets timestamp