Hello good afternoon.
I am new to using document and spreadsheet scripts and created a script for an inventory control spreadsheet in which emails are sent to me when a particular product reaches its minimum and critical capacity.
The script I programmed works normally when it is manually triggered by an execution in the script editor. However, when I create a time trigger for the same one that performs the sending of emails to me once a day, the trigger works and runs normally with the status of completed but the emails do not arrive as when it is executed manually.
This is the script:
/**
* Envia email com dados da planilha atual.
*/
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // linha inicial de dados
var numRows = 30; // número de linhas para processar
// Busca no intervalo as células A2:F6
var dataRange = sheet.getRange(startRow,1,numRows,6);
// Busca valores para a linha no intervalo.
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
var emailAddress = row[0]; // coluna 1 - email
var subject = row[1]; // coluna 2 - assunto
var messagemin = row[2]; // coluna 3 - mensagem minimo
var messagecrit = row[3]; // coluna 3 - mensagem critico
var quanti = row[4]; //coluna 4 - quantidade atual crítica ou mínima
var item = row[5]; //coluna 5 - item que corresponde aos dados anteriores
if ((quanti<=3) && (quanti>2) && (item =='Álcool')) { //minimo
MailApp.sendEmail(emailAddress, subject, messagemin);
}
if ((quanti<=2) && (quanti>=0) && (item =='Álcool')) { //critico
MailApp.sendEmail(emailAddress, subject, messagecrit);
}
}
}
(String, number, number, number) do not match the method signature for SpreadsheetApp.Spreadsheet.getRange. (line 9, file "Codigo").
I don't know what it can be.
Hi, thanks.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4911525b-0ecb-4b24-8d68-d98ba778f08c%40googlegroups.com.