Reputation: 1
So I have this code in my google sheets script editor right now. Pretty much what I'm trying to do is set a function that when a specific edit occurs in a designated column that it'll send out an email to the email address that's in an adjacent cell in that row that had the edit occur.
I keep getting this error though: TypeError: sheet.getRange(...).getvalue is not a function (line 4, file "Code")
Here's the code I have so far:
function checkvalue(e) {
var ss=SpreadsheetApp.getActive();
var sheet=ss.getSheetByName("Scheduling");
var valueToCheck=sheet.getRange("A1").getvalue();
var rangeEdit=e.range.getA1Notation();
if(rangeEdit=="A1"){
if(valuetocheck="NEEDS RESCHEDULED"){
// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Scheduling").getRange("columnQ");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var message = 'MYMESSAGE'; // Second column
var subject = 'MYSUBJECT';
MailApp.sendEmail(emailAddress, subject, message);
}
}
}
,,,
Upvotes: 0
Views: 117
Reputation: 64052
var valueToCheck=sheet.getRange("A1").getvalue();
should be var valueToCheck=sheet.getRange("A1").getValue();
also:
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Scheduling").getRange("columnQ");
should be `var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Scheduling").getRange(1,17,SpreadsheetApp.getActiveSheet().getLastRow(),1);
And possibly others
Upvotes: 1