Function 如何使onEdit函数适应特定值的激发
在“onEdit”函数中,我在本论坛或elswhere中找到的所有示例都包含相同(或类似)行来定义源代码,如:Function 如何使onEdit函数适应特定值的激发,function,google-sheets,Function,Google Sheets,在“onEdit”函数中,我在本论坛或elswhere中找到的所有示例都包含相同(或类似)行来定义源代码,如: if( r.getColumn() == 5 ) { //checks updates in column E 我无法找到如何对此进行调整,但我希望仅当列设置为特定值时,我的OneEdit函数才会启动: if value of column E is set to "done" then perform rest of the function 试着这样做: 函数onEdit(e)
if( r.getColumn() == 5 ) { //checks updates in column E
我无法找到如何对此进行调整,但我希望仅当列设置为特定值时,我的OneEdit函数才会启动:
if value of column E is set to "done" then perform rest of the function
试着这样做:
函数onEdit(e){
if(e.range.getColumn()==5&&e.value.toLowerCase()===done')
Logger.log('Todo');
}
请参阅。我用以下脚本解决了这个问题:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "TaskBoard" ) { //checks that we're on the correct sheet; "TaskBoard"
var r = s.getActiveCell();
if( r.getColumn() == 2 ) { //checks updates in column B
var cellContent = r.getValue();
if (cellContent == 'Done')
{
var nextCell = r.offset(0, 4); //offset to same row, and column F; B+4
if( nextCell.getValue() === '' ) //is empty?
{
var time = new Date();
time = Utilities.formatDate(time, "CET", "yyyy-MM-dd");
nextCell.setValue(time);
}
}
};
};
}