Tuesday, 15 April 2014

Trigger email if cell changed in Google Sheet -



Trigger email if cell changed in Google Sheet -

i have sheet track section metrics in google sheets. trying email when metric changes. using counta (in range p2) monitor if new metric came in , want trigger email if value in range changes.

function onedit() { var ss = spreadsheetapp.getactivespreadsheet(); var value = ss.getsheetbyname("emailservices").getrange("p2").getvalue().tostring(); var lastly = scriptproperties.getproperty("last"); if(value != last) { scriptproperties.setproperty("last",value); mailapp.sendemail("dave@mydomain.com", "cell p2 changed", "new value: " + value + "\n\n" + ss.geturl()) } }

i have trending charts , i'd email actual trending chart changed (a new monthly value entered) thought i'd walk before ran. :)

cells alter because of formula not qualify 'edit' trigger onedit function. should either monitor source cell(s) (if edited manually) or sec alternative have function running under trigger runs every min (or whatever frequency like) , send out email. function you've written looks run under trigger.

google-apps-script

No comments:

Post a Comment