I think it's for experts. There it is, step by step:
- I created a Google Spreadsheet
- The following script is running on it:
/*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);}
}
}
}
- This spreadsheet is shared with other users, as editors
- Some intervals are restrict for some editors
THE ISSUE
When the Owner updates the two described columns (see the above code), the script works fine
When shared editors modify something, just the second condition (if) of the script is working
Can someone help me on this?
Is there a problem with the script, maybe? Why does it works properly just on the spreadsheet owner?