Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:34:09+00:00 2026-06-18T15:34:09+00:00

I have a script that is supposed to mail a chart URL when a

  • 0

I have a script that is supposed to mail a chart URL when a metric falls out of X range and Only if someone has entered a new metric. It’s mailing everytime I run the script so I know the setProperty is not working and the “if” statement isn’t working because it’s only supposed to mail if X is TRUE.

The sheet… https://docs.google.com/spreadsheet/ccc?key=0Ai_2YLvaQba0dHN1dWFpY0ZSbGpudWF4cTJYNlFwNHc&usp=sharing

My code…

function myAverages() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var value = ss.getSheetByName("EmailServices").getRange("P2").getValue().toString();
  var outside = ss.getSheetByName("EmailServices").getRange("S2").getValue().toString;
  var mailed = ss.getSheetByName("EmailServices").getRange("T2").getValue().toString();
  var stemiAverage = ss.getSheetByName("EmailServices").getRange("R2").getValue().toString();
  var stemiChart = ss.getSheetByName("EmailServices").getRange("U2").getValue().toString();
  var last = ScriptProperties.getProperty('last');

  //if "value" is not equal to ScriptProperty "last" AND "outside" is TRUE, then mail   
  if(value =! last, outside = "TRUE")

  {
   MailApp.sendEmail("dave@mydomain.com", "Metric Warning",
    "Yearly STEMI Average has fallen below 65%, it is now: " + stemiAverage + "%" +
    "\n\nTo see the current trending chart " + stemiChart + "\n\n The sheet that    calculated this is here " + ss.getUrl());
   ScriptProperties.setProperty('last','value');
  }
}

Thanks for any help you can lend. I’m teaching myself this stuff and feel very much like a newby. I’ve tried a hundred or more combinations to the script before posting here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:34:10+00:00Added an answer on June 18, 2026 at 3:34 pm

    As a complement to Phil’s answer and following your comment, there is another error in your script :

       ScriptProperties.setProperty("last","value");
    

    should be

       ScriptProperties.setProperty({'last':value},true);
    

    The true parameter is optional, see documentation on ScriptProperties, it gives you the possibility to delete all other keys.

    So you’re complete function with corrections would be :

    function myAverages(){
          var ss = SpreadsheetApp.getActiveSpreadsheet();
          var value = ss.getSheetByName("EmailServices").getRange("P2").getValue().toString();
      Logger.log('value = '+value)    
          var outside = ss.getSheetByName("EmailServices").getRange("S2").getValue().toString();
      Logger.log('outside='+outside)
          var mailed = ss.getSheetByName("EmailServices").getRange("T2").getValue().toString();
      Logger.log('mailed = '+mailed)    
          var stemiAverage = ss.getSheetByName("EmailServices").getRange("R2").getValue().toString();
          var stemiChart = ss.getSheetByName("EmailServices").getRange("U2").getValue().toString();
          var last = ScriptProperties.getProperty('last');
      Logger.log('last='+last)    
           if(value != last && outside == "true"){
              MailApp.sendEmail("me@mydomain.com", "Metric Warning",
              "Yearly STEMI Average has fallen below 65%, it is now: " + stemiAverage + "%" +
              "\n\nTo see the current trending chart " + stemiChart + "\n\n The sheet that    calculated this is here " + ss.getUrl());
              ScriptProperties.setProperty({'last':value});
      Logger.log('mail sent')
             }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that's supposed to take in a URL and search
I have a script that is supposed to sit there, happily running in a
I have a function in a powershell script that is supposed to untar my
I have a Ruby 1.8.6 script that is supposed to take a filename that
I have a Perl script, that's supposed to match this string: Sometimes, he says
I have this script that is supposed to insert the information into a MySQL
I've setup an Amazon EC2 server. I have a Python script that is supposed
I have a simple PHP script that is supposed to redirect to another document
I have a working mailer script which has already started sending out mails. We
I have a script task in an SSIS package that is supposed to retrieve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.