Hello
I am running a program to compare values in two different sheets. The function is trigerred every minute. What i want is for some statements to execute the first time the comparision results evaluate to true. After that it should not execute the statements.
I have declared a global variable and initialized it to 0. When the condition evaluates to true the first time I am setting the global variable to 1. I am resetting it to 0 later in else block. The problem is everytime the function is trigerred the variable is getting initialized to 0. It is not retaining the value of 1 which I assigned in the previous run. Is there an alternate way I can do this.
Attaching a snippet of the relevant code. Please ignore syntax errors if any.
//Global variable
mail_trigerred = 0;
send_email() //Trigerred every minute
{
//other lines of code are here.
if (last_value_h.join() == last_value_u.join())
{
if (mail_triggered == 0)
{
Logger.log(mail_triggered);
var message= 'Hello';
var subject = 'Not working';
MailApp.sendEmail(emailAddress2,subject,message);
mail_triggered = 1;
}
}
else
{
mail_triggered = 0;
archive();
}
}