2

I'm having trouble finding a Google sheet script that does what I need so I figured I would ask if someone could help me. Basically I have a simple sheet setup to track inventory of one item. There is a formula in "G1" on sheet "QAI Stickers" that calculates the remaining inventory and I would like to add a script that emails specific people when the value drops below 11. I also just want it to email when just that value changes and not just when any value in the sheet changes.

Here is what I've been trying to use. I have a trigger setup to run on edit, but it seems to only run if I push play on the script. The program is also telling me that lines 5 & 8 are deprecated.

 function myNotification() {  
  var ss = SpreadsheetApp.getActiveSpreadsheet();  
  var value = ss.getSheetByName("QAI Stickers").getRange("G1").getValue();  
  if( value < 11 ) {  
    var last = ScriptProperties.getProperty("last");  
    value = value.toString();  
    if( value != last ) {  
     var email = Session.getUser().getEmail();  
     MailApp.sendEmail(email, 'My Notification',  
                    'new value: '+value+'\n\n'+ss.getUrl());  
     ScriptProperties.setProperty("last", value);  
    }  
  }  
}  
2
  • Ok, I added the script that I have been trying to use. I can kind or get the basics of what the script is doing if I see it written out, but I really have no clue how to write one of these... Commented Jun 2, 2017 at 17:47
  • Thanks! Much easier for someone to gauge where you are in the process.
    – jonsca
    Commented Jun 2, 2017 at 23:19

1 Answer 1

0

Make use of triggers to run your script automatically. See Triggers and events Guide

Regarding the deprecrated lines, instead of ScriptProperties we should use the Properties Service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.