I am a basketball coach & I am creating a dashboard to monitor my players' social media. I'm using IFTTT.com to pull in all of my players' tweets in real-time to a spreadsheet. I'm trying to write a code that if one of my players uses an inappropriate word, it'll trigger an email to me of that cell. I feel like I'm on the right track, but some guidance on my code is greatly appreciated.
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet()
var cell = ss.getActiveCell().activate();
Logger.log( cell.getA1Notation() );
if (cell.getValue().match("ass")) {
MailApp.sendEmail("example@example.com", "Notice of possible inappropriate tweet", cell;}
}`
This is the code for just one inappropriate word, obviously, as I'm just trying to get the basics of the coding down before I add 100 inappropriate words. The trouble is that if the sheet pulls in three tweets at the same time, it's only going to check on the last one, so that's where my main troubles lie right now.
Any guidance or help here is greatly appreciated!
I agree with Camerons comments above, if you can describe what's not working for you specifically, that would give us an idea of what you need help with.
As it stands, your code runs for me, and it will email me when I edit a cell to contain the word 'ass'.
However, one catch is that currently in the body of the email you have the variable 'cell' which will only return the word 'range'.
Here's a slightly updated version that provides more helpful notation in the email: