我認爲這是專家。就在那兒,一步一步:Google Spreadsheet權限
- 我創建了一個谷歌電子表格
- 下面的腳本在其上運行:
/*Updated and maintain by internetgeeks.org*/
function onEdit(event)
{
var timezone = "GMT-3"; var timestamp_format = "dd-MM HH:mm"; // Timestamp Format.
if (updateColName = "Nº Cotação") {
var sheet = event.source.getSheetByName('Cotações'); //Name of the sheet where you want to run this script.
var updateColName = "Nº Cotação"; var timeStampColName = "Data proposta";
var actRng = event.source.getActiveRange();
var editColumn = actRng.getColumn();
var index = actRng.getRowIndex();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
var dateCol = headers[0].indexOf(timeStampColName); var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol+1;
if (dateCol > -1 && index > 1 && editColumn == updateCol) { // only timestamp if 'Last Updated' header exists, but not in the header row itself!
var cell = sheet.getRange(index, dateCol + 1);
var date = Utilities.formatDate(new Date(), timezone, timestamp_format); cell.setValue(date);}
if (updateColName = "Resposta ao Cliente") {
var sheet = event.source.getSheetByName('Cotações'); //Name of the sheet where you want to run this script.
var updateColName = "Resposta ao Cliente"; var timeStampColName = "Contatado";
var actRng = event.source.getActiveRange();
var editColumn = actRng.getColumn();
var index = actRng.getRowIndex();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
var dateCol = headers[0].indexOf(timeStampColName); var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol+1;
if (dateCol > -1 && index > 1 && editColumn == updateCol) { // only timestamp if 'Last Updated' header exists, but not in the header row itself!
var cell = sheet.getRange(index, dateCol + 1);
var date = Utilities.formatDate(new Date(), timezone, timestamp_format); cell.setValue(date);}
}
}
}
- 此電子表格與共享其他用戶,作爲編輯
- 某些間隔限制某些e ditors
問題
當所有者更新兩個描述列(見上面的代碼),腳本工作正常
當共享編輯修改的東西,只是第二條件(如果)的腳本正在工作
有人可以幫助我嗎?
腳本有問題嗎?爲什麼它只能在電子表格所有者上正常工作?
http://pt.stackoverflow.com/help/dont-ask可能是有趣的。 – pnuts
看起來'updatedColName'是'undefined'。見http://stackoverflow.com/q/16089041/1595451 –